How do I make a part get destroyed when a tool touches it. There is a local script inside the part that I want to be deleted, the code for it is:
script.Parent.Touched:Connect(function(hit)
game.ReplicatedStorage.OpenMediumDoorEvent:FireServer(hit)
end)
The remote event is inside ReplicatedStorage and the script that will handle the remote is in ServerScriptService, the code for that script is as follows:
game.ReplicatedStorage.OpenMediumDoorEvent.OnServerEvent:Connect(function(hit)
if hit.Parent.Name == "MediumKey" then
game.Workspace.Medium.MediumTeleport.PartToBeDeleted:Destoy()
end
end)

12 comments
Unfortunately, changing Destoy() to Destroy() and adding a "player" parameter on the OnServerEvent script still didn't solve my problem, nothing appeared in Output too.
I've added a few prints. What does it print?
Nothing. It prints nothing.
Where is the LocalScript located? (ReplicatedFirst, StarterPlayerScripts, Workspace, etc.)
The local script is located inside a part, which is inside a model with other parts, the model's parent is another model and that model's parent is a folder and that folder's parent is the Workspace.
LocalScript's do not work in the Workspace. They only run in: ReplicatedFirst, StarterCharacterScripts, StarterPlayerScripts, and a player's character.
Thanks! Now that I know that local scripts don't work in Workspace, I made my project work!
No problem. Please accept my answer.
How? I'm new to Scripting Helpers.
It should be under my post. There's also been a bug where new users can't accept an answer without going into incognito mode. If you don't see the button then do that.
Done!
Thank you.