Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Editing a script to make it delay when touched?

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.

1 comment

0

So you need the Raider to stay on it for 15 seconds, if he comes off it stops?

1 answer

wait(15)??

2 comments

0

wait(15) just pauses a thread for 15 seconds. He asking a delay of 15 seconds before being capable of capturing a flag.

0

^^

This discussion is preserved as it was. New answers, comments, and votes are closed.