Need help destroying a part for only the player who touched it

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Destroy a Part for only the player who clicks it

32 What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried sending a remote event when the player clicks it but it does not work, I need this for a punch wall game I found a way to make it work, but It shows for the whole server which defeats the purpose

Can we have your old code and the location of the scripts (parent)?

The location of part:
image
The part script: (Child of part)

– Reference to the RemoteEvent
local remoteEvent = Instance.new(“RemoteEvent”)
remoteEvent.Name = “DestroyPart”
remoteEvent.Parent = game.ReplicatedStorage.RemoteEvents

local part = script.Parent.Parent:WaitForChild(“1”)
local world = workspace.World1

script.Parent.ClickDetector.MouseClick:Connect(function(player)
– Fire the RemoteEvent to notify the client to update locally
remoteEvent:FireClient(player, player.leaderstats.Strength.Value, part.Name, world.Name)
end)

The Client Script (StarterPlayer)
– Function to handle the event fired from the server
game.ReplicatedStorage.RemoteEvents.SendClick.OnClientEvent:Connect(function(strengthValue, partName, worldName)
local TargetWorld = workspace:FindFirstChild(worldName)
if TargetWorld then
local Part = TargetWorld:FindFirstChild(partName)
if Part then
Part.Value.Value = Part.Value.Value - strengthValue
Part.GuiDisplayer.TextLabel.Text = Part.Value.Value
else
warn(“Part not found in DigLayer:”, partName)
end
else
warn(“World not found:”, worldName)
end
end)

Local scripts do not run in the workspace, only server scripts do. I would recommend placing the local script in StarterPlayer < StarterPlayerScripts and editting scripts accordingly

I did that local script is a test

The script i sent (local script) is the one in starterplayer

Nvm fixed it, had wrong remote-event names!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.