Jump to content

having problems here help please :)


battle309

Recommended Posts

Posted

hey i made this script but it doesnt work its meant to wait until someone reaches five minutes then they win and the map changes. but if they die there time is reset is this script made right or have i mad any errors of any sort.

 function winGame() 
    local count = 0 
        setTimer ( winGame, 1000, 1 ) 
        if count== 300 then 
givePlayerMoney ( player, 25000 ) 
            outputChatBox("You have won!") 
        else 
            count = count + 1 
  
    end     
end 
  
addEventHandler ( "onPlayerSpawn", getRootElement(), winGame ) 

Posted

You should use a timer. In this case function will be executed only ONCE, and count will be ALWAYS resetted every time the function initializes since it says: local count = 0. It will always be 0 or 1

Posted

It wont because you defined count = 0. It will always be resetted.

You should write OVER function:

local count = 0

and then inside the function, remove the localCount.

and then, if count == 300 then, you can also set count = 0

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...