so i want to make an obstacle where a player has to travel across two parts but in between i want a killbrick that goes of repeatedly after waiting a certain amount of time
this is the script i have rn but im not sure what to do anymore
block = script.Parent while wait(10) do block.BrickColor = BrickColor.new(105,14,0) function onTouched(Obj) local h = Obj.Parent:FindFirstChild("Humanoid") if h then h.Health = 0 block.BrickColor = BrickColor.new(0,0,0) end end script.Parent.Touched:Connect(onTouched) end
can someone help please?
This is what you want?
local block = script.Parent block.BrickColor = BrickColor.new(105,14,0) function onTouched(Obj) local h = Obj.Parent:FindFirstChild("Humanoid") if h then h.Health = 0 block.BrickColor = BrickColor.new(0,0,0) script.Disabled = true wait(10) script.Disabled = false block.BrickColor = BrickColor.new(105,14,0) end end script.Parent.Touched:Connect(onTouched)
If you want to make it randomly,try this
local block = script.Parent coroutine.resume(coroutine.create(function() while true do script.Disabled = false block.BrickColor = BrickColor.new(105,14,0) wait(math.random(1,15)) script.Disabled = true block.BrickColor = BrickColor.new(0,0,0) wait(math.random(1,15)) end) end) function onTouched(Obj) local h = Obj.Parent:FindFirstChild("Humanoid") if h then h.Health = 0 end end script.Parent.Touched:Connect(onTouched)
wait nvm i got it, i just inserted this script into serverscript service
kill = game.Workspace.Kill while wait() do kill.KillScript.Disabled = true wait(3) kill.KillScript.Disabled = false wait(3) end