Hello! I’m having an issue where my local script happens for all the clients. I want it so it only breaks the boulders on your screen. But for some reason when I did a Local server test the boulders broke for all of the players. Please let me know if I’m doing something wrong! Also, this is in Starter Gui
local boulderHitBox = game.Workspace.SpawnPlace.BouldersHitBox
local boulder = game.Workspace.SpawnPlace.Bolders
local boulderChildren = boulder:GetChildren()
local rockBreakingSound = game.Workspace.SpawnPlace.RocksBreaking
local swordErrorText = script.Parent.SwordErrorText
boulderHitBox.Touched:Connect(function(sword)
if sword.Parent.Name == "FirstSword" then
boulderHitBox:Destroy()
for i,v in pairs(boulderChildren) do
v:Destroy()
end
rockBreakingSound.Playing = true
else
swordErrorText.Visible = true
end
end)
boulderHitBox.TouchEnded:Connect(function()
swordErrorText.Visible = false
end)
boulderHitBox.Touched:Connect(function(sword)
if sword.Parent.Name == "FirstSword" then
boulderHitBox:Destroy()
for i,v in pairs(boulder:GetChildren()) do
v:Destroy()
end
rockBreakingSound.Playing = true
else
swordErrorText.Visible = true
end
end)
boulderHitBox.TouchEnded:Connect(function()
swordErrorText.Visible = false
end)
I tried getting a var for children before it didnt work
There isn’t an error. The only thing that’s happening is that the boulders are breaking for all of the clients but I only want the boulders to break for the person who broke them
So I see why. Your detecting when the boulder is touched it destroys! But every client is gonna get this message when the part is touched. Every client is getting it because your not detecting when the part is touched.
Correction, the Touched event is being fired when 1 person touches it.
if sword.Parent.Name == "FirstSword" then
if sword.Parent.Parent:FindFirstChild("Humanoid") then -- add/remove parents until it points to the player's Character
if game.Players.LocalPlayer.Name == sword.Parent.Parent.Name then
boulderHitBox:Destroy()
for i,v in pairs(boulder:GetChildren()) do
v:Destroy()
end
rockBreakingSound.Playing = true
else
swordErrorText.Visible = true
end
end
end
end)
boulderHitBox.TouchEnded:Connect(function()
swordErrorText.Visible = false
end) ```
Yes, now you need to check if the player who touched it is the local player. Right now, it will detect when the boulder is touched. If ANYONE or ANYTHING touches it, it will delete.