Hey I want To make A tool when activated It turns every part that touches the handle red after 10 seconds it stops. But it is not working at all. I used many scripts and none is working. This is the last script I used:
local Yes = false
if Yes == false then
script.Parent.Orientation = Vector3.new(0,0,0)
end
if Yes == true then
script.Parent.Orientation = Vector3.new(-90, 0, 0)
script.Parent.Touched:Connect(function(Part)
Part.BrickColor = BrickColor.Red()
end)
end
script.Parent.Parent.Activated:Connect(function(act)
Yes = true
wait(10)
Yes = false
end)
local Yes = false
coroutine.wrap(function()
while task.wait() do
if Yes == true then
script.Parent.Orientation = Vector3.new(-90,0,0)
else
script.Parent.Orientation = Vector3.new(0,0,0)
end
end
end)()
script.Parent.Touched:Connect(function(Part)
if Part:IsA("BasePart") and Yes then
Part.BrickColor = BrickColor.Red()
end
end)
script.Parent.Parent.Activated:Connect(function(act)
Yes = true
wait(10)
Yes = false
end)
I fixed your code, maybe this will work out for you
This doesn’t listen to changes, this just checks it once then stops.
Either, wrap it in a loop or make a function to execute it:
local Yes
local function Check(val)
if val == false then
script.Parent.Orientation = Vector3.new(0,0,0)
else
script.Parent.Orientation = Vector3.new(-90, 0, 0)
script.Parent.Touched:Connect(function(Part)
Part.BrickColor = BrickColor.Red()
end)
end
end
script.Parent.Parent.Activated:Connect(function(act)
Yes = true
Check(Yes)
wait(10)
Yes = false
Check(Yes)
end)
did you even type in the script when yes is true that happens?
in your script, it just said when val is true the thing happens but you didn’t do anything with the yes