Local script that destroys part

i want to have my script only destroy a part for the client and not for other players but currently my script does nothing and gives no errors

here is my local script located in ServerScriptService:

game.Workspace.SpawnArea.SpawnDoor:Destroy()

this script will be disabled by default once working and will be enabled by another script

local scripts dont work in ServerScriptService, place the script in StarterPlayer → StarterPlayerScripts

1 Like

Local scripts won’t run there.
Try to put it in StarterGui.

Local Scripts would run only in these places:
-StarterGui
-ReplicatedFirst
-StarterPlayerScripts
-StarterCharacterScripts
-Chat

Also, you should use WaitForChild, because sometimes that part might hasnt loaded yet.

1 Like

LocalScripts do not run here.


Try using RunContext.

1 Like

i have changed my script into this and moved it to ReplicatedFIrst

game.Workspace:WaitForChild("SpawnArea")

game.Workspace.SpawnArea.SpawnDoor:Destroy()

and it now works, ty

Note that you should assign this as a variable. Like -

local SpawnArea = game.Workspace:WaitForChild("SpawnArea")