Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Remove a part locally by touching another part locally?

Asked by 1 year ago

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

Log in to vote
0
Answered by 1 year ago

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)
0
Works perfectly! ayyPepes 0 — 1y
0
Worked thanks! ayyPepes 0 — 1y
0
Your welcome! please accept my answer so everyone can see! T3_MasterGamer 2189 — 1y
0
You should place it in StarterPlayerScripts over StarterGui, kodymarcey 49 — 1y
0
ok T3_MasterGamer 2189 — 1y
Ad

Answer this question