Hello there! so i made a fun simple script, when a player clicks a wood part, it unanchors, and supposed to be pushed by CFrame.
I want it to wait two seconds and then disable the script, so it will not continue the CFrame sentence forever.
However, the wait(2) thing, interrupts the while true do sentence.
is there any way to make the script disabled after a certain wait of time without interrupting a while true do sentence? It’s very annoying.
thank you.
script:
local Click = script.Parent
local Breakable = script.Parent.Breakable
local Part = script.Parent.Parent
local Effect = script.Parent.Parent.Effect
Click.MouseClick:Connect(function()
if Breakable.Value == true then
Part.Anchored = false
Effect.Enabled = true
wait(2)
Effect.Enabled = false
Part.Orientation = Vector3.new(45, 0, 0)
while true do -- Loop
Part.CFrame = Part.CFrame * CFrame.new(0, 0, 10)
wait(2)
script.Disabled = true -- Disable script | stop
wait()
end
end
end)
Well of course the script gets disrupted, lol. You said “script.Disabled = true.” The script is no longer able to run any lines because it got disabled. What are you trying to accomplish by adding that into your code?
no, the thing is, that I want it to wait Two seconds and then disable the script, but the while true do thing waits 2 seconds so it looks like the CFrame is lagging.