I need help in my script

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?

Maybe Remove “Script.Disabled = True” Then The Script Might Work?

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.

1 Like

Would you like me to Join your Studio And check the Script? ill be glad too.

Yes, that’d be helpful thank you

Alright Invite me to your Studio.

Also Tell me the name of the Game

it’s being called tc I invited you.

1 Like

Theres Nothing, Go to “Game Settings” Then Click “permission” Then Type iiStormChaserlaw it’s the One with the glasses

It Says “Play” i Need Edit’s Click The View Then Click Team Create Then Turn on Then There!

It’s already On, I can’t give you perms to edit for some reason.

try friending Me might work…

That’s Weird, I don’t Know why it doesn’t work.

same, nevermind it’s fine, thank you anyways, My laptop charger is dying rn I’ll maybe see later thanks!

Alrighty Then, Thank you for Allowing me to Kinda Help

1 Like

:+1:t6: all good, thanks, you can friend me if you want I might need help.

Alrighty Thank you ill Do that After my Development Session, Thank you Send me a message if you need something.

You can break the loop.
30 charrrrrrrs