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
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.