Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Editing a script to make it delay when touched?

Asked by 10 years ago

Hi guys. My good friend helped me with this script and I'm a bit stuck on it. I need to make it delay for about 15 seconds before it makes changes. As in, if you are on the raiders team, you go and step on it, it takes 15 seconds before it starts capturing. Can anyone help me with this?

Thank you :)

timeuntilwin = 1200 --Change to the amount of time raiders must hold the brick (in seconds). 
totaltime = 1200 --Make this equal to "timeuntilwin". 

raidteamcolor = "Bright red" --Change to raider team color. Remember, colors are case sensitive!
defendteamcolor = "Dark stone grey" --Change to defenders' team color.  

h = Instance.new("Hint") 

function OnTouched(hit) 

    if hit.Parent:findFirstChild("Humanoid") ~= nil then 
        if game.Players:GetPlayerFromCharacter(hit.Parent).TeamColor == BrickColor.new(raidteamcolor) then 
                script.Parent.BrickColor = BrickColor.new(raidteamcolor) 
        end 

        if game.Players:GetPlayerFromCharacter(hit.Parent).TeamColor == BrickColor.new(defendteamcolor) then
                script.Parent.BrickColor = BrickColor.new(defendteamcolor) 
                timeuntilwin = totaltime  
                for i, v in pairs(game.Workspace:GetChildren()) do 
                    if v:IsA("Hint") then 
                            v:remove() 
                    end 
                end 
        end 

    end 

end 

script.Parent.Touched:connect(OnTouched) 

                while true do 
                        wait()
                    if script.Parent.BrickColor == BrickColor.new(raidteamcolor) then 
                        h.Parent = game.Workspace 
                        h.Text = "Raiders win in".." "..timeuntilwin 

                        if timeuntilwin <= totaltime  and timeuntilwin > 0 then 
                        wait(1) 
                        timeuntilwin = timeuntilwin - 1 
                        end

                        if timeuntilwin == 0 then 
                            h:remove() 

                            winmsg = Instance.new("Message") 
                            winmsg.Parent = game.Workspace 
                            winmsg.Text = "Raiders have won!" 
                            wait(5) 
                            winmsg:remove()

                            script.Parent.BrickColor = BrickColor.new(defendteamcolor) 
                            timeuntilwin = totaltime
                        end 
                    end 
                end 

Please be as descriptive as possible, because I'm incredibly new at scripting.

0
So you need the Raider to stay on it for 15 seconds, if he comes off it stops? c0des 207 — 10y

1 answer

Log in to vote
-1
Answered by
aews5 15
10 years ago

wait(15)??

0
wait(15) just pauses a thread for 15 seconds. He asking a delay of 15 seconds before being capable of capturing a flag. soaprocks2 75 — 10y
0
^^ firedum 5 — 10y
Ad

Answer this question