Hi
So i made a script where you click a gui button and it destroys a script in workspace. the problem is, the script keeps running. I’ve tried many different ways at disabling and destroying the script but it does not work.
Code for button
If you are destroying script from a localscript, it will not be removed for the server only the client. To fix this use a RemoteEvent telling the server to destroy it.
As @Odawg566 said, when using local scripts it would only delete the script on the client, so it would still run on the server.
Instead run this code:
--Client sided script
local remote = game.ReplicatedStorage.YourRemoteEventHere
--Fire the event with whatever code you were using
remote:FireServer()
Server Code:
local remote = game.ReplicatedStorage.YourRemoteEventHere
remote:OnServerEvent:Connect(function() --Args like a normal function.
game.Workspace.Orbits.EarthOrbit.MoveScript.Disabled = true
game.Workspace.Orbits.EarthOrbit.MoveScript:Destroy()
end)
Ignore my formatting, the devforum sucks for code.