Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Remove a part locally by touching another part locally?

Hello, I am trying to remove a part by touching another and the part locally but the part I touched gets deleted on the server

Simpler way to explain: I touch part B, it destroys part A to the person who touched it, part B is deleted on the server

Script on Part B

script.Parent.Touched:Connect(function(hit) script.Parent:Destroy() end)

Local script on Part B

function onTouch(part) game.ReplicatedStorage.PINK:FireServer() end

script.Parent.Touched:connect(onTouch)

Local script I have on Part A

game.ReplicatedStorage.PINK.OnClientEvent:Connect(function() script.Parent:Destroy() end)

It destroys part B but doesn't destroy part A

1 answer

local scripts doesn’t work in workspace. try putting the local script in startergui and the local scripts should be like this

part a local script (in startergui)

game.ReplicatedStorage.PINK.OnClientEvent:Connect(function() workspace.PartA:Destroy() end)

part b script (in workspace inside of part b)

script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
script.Parent:Destroy()
game.ReplicatedStorage.PINK:FireClient(game.players:GetPlayerFromCharacter(hit.Parent))
end
end)

5 comments

0

Works perfectly!

0

Worked thanks!

0

Your welcome! please accept my answer so everyone can see!

0

You should place it in StarterPlayerScripts over StarterGui,

0

ok

This discussion is preserved as it was. New answers, comments, and votes are closed.