I'm making a mining game, and I made a pickaxe tool for this. But when one player mines a part, other people can still see this part. This is the script in the pickaxe, any idea how to fix it? It's in a local script by the way.
local Players = game:GetService("Players")
local localPlayer = script.Parent.Parent.Parent
local backpack = localPlayer:WaitForChild("Backpack")
local tool = script.Parent
local clicks = 0
tool.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
clicks = clicks + 1
if mouse.Target.Parent then
if (mouse.Target.Position - localPlayer.Character.HumanoidRootPart.Position).Magnitude < 15 then
if mouse.Target.Name == "GrassBlock"then
mouse.Target:Destroy()
elseif mouse.Target.Name == "StoneBlock"then
if clicks > 2 then
mouse.Target:Destroy()
clicks = 0
end
end
end
end
end)
end)

2 comments
you need to send the destory to the server try remote functions https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
if you change the workspace using a local script it only changes for that one client, not the server