Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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
0
Have you tried disabling the script Omzure 94 — 3y
0
tbh idek if that works but you can try Omzure 94 — 3y
0
ok i'll try AriyanHacker29 22 — 3y
0
wait what do u mean?? How can i do that AriyanHacker29 22 — 3y
0
script.DIsabled = true Omzure 94 — 3y

1 answer

Log in to vote
0
Answered by
Dexiber 272 Moderation Voter
3 years ago
Edited 3 years ago

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.

0
it didn't disable the tween AriyanHacker29 22 — 3y
0
now it should work Dexiber 272 — 3y
0
it still does not work AriyanHacker29 22 — 3y
0
is there some sort of rule for disabling tween?? AriyanHacker29 22 — 3y
View all comments (4 more)
0
tweenBase:Stop() ? Dexiber 272 — 3y
0
what do i do with that? AriyanHacker29 22 — 3y
0
ill edit the answer ok! Dexiber 272 — 3y
0
ok but if that doesn't work then i'll just kill the object AriyanHacker29 22 — 3y
Ad

Answer this question