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

How to make another script stop running after it has been destroyed?

The script below destroys the other script which is just a tween move script but after it destroys the script, the script that has been destroyed still runs. That means its gone from the workspace but it still has the effects. Why is that and how can i fix it? Also i am new to scripting so please don't criticize me, thnx

local CurrentPos = workspace.touchablepart.Position

if workspace.touchablepart.ClickDetector.MouseClick then
	workspace.MoveScript:Destroy()
elseif workspace.touchablepart.ClickDetector.MouseHoverEnter then
	wait (.5)
	workspace.touchablepart.Position = CurrentPos + Vector3.new(2,0,0)
end

5 comments

0

Have you tried disabling the script

0

tbh idek if that works but you can try

0

ok i'll try

0

wait what do u mean?? How can i do that

0

script.DIsabled = true

1 answer

you cant destroy the script and make it not run anymore (at least i think.)

you also cant do this: if workspace.touchablepart.ClickDetector.MouseClick then

do this instead:

local CurrentPos = workspace.touchablepart.Position

   workspace.touchablepart.ClickDetector.MouseClick:Connect(function()
    workspace.MoveScript.Disabled = true
end)

workspace.touchablepart.ClickDetector.MouseHoverEnter:Connect(function()
    wait (.5)
    workspace.touchablepart.Position = CurrentPos + Vector3.new(2,0,0)
end)

this should work.

8 comments

0

it didn't disable the tween

0

now it should work

0

it still does not work

0

is there some sort of rule for disabling tween??

0

tweenBase:Stop() ?

0

what do i do with that?

0

ill edit the answer ok!

0

ok but if that doesn't work then i'll just kill the object

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