Erase tool not working?

Hello Developers! im trying to make a eraser where if its in eraser mode. It will erase the frame that the mouse enter. It worked but… It only works on client instead of everyone on the server.

Heres the script i created:

Server Script

	local InviteId = script.Parent.Name
	for _, user in pairs(game.Players:GetChildren()) do
		local UserGui = user.PlayerGui
		local PIXEL = UserGui:WaitForChild("GameGui", 60):FindFirstChild(InviteId).DrawingBoard:FindFirstChild(RemovePixelName)
		PIXEL:Destroy()
	end
end

game.ReplicatedStorage:FindFirstChild(script.Parent.Name).EraseEvent.OnServerEvent:Connect(RemovingPrints)

Client Script

local function EnteredPixel()
	if script.Parent.Parent.Parent.LocalScript.ToolUsing.Value == "Eraser" then
		local RemovePixelName = script.Parent.Name
		game.ReplicatedStorage:FindFirstChild(script.Parent.Parent.Parent.Name).EraseEvent:FireServer(RemovePixelName)
	end
end
script.Parent.MouseEnter:Connect(EnteredPixel)

Note: I used events to fire server on which frame to remove in the server from client. Player 1 is working, Player 2 doesn’t work

Try using WaitForChild for all variables

it’s still desame, but what happen is. It worked to Player1 but what happened to Player2 is:


and yep, i just noticed the error just now

it finally worked! it was because the player1 joined so the script runs while player2 haven’t joined! and I’ll solution you since you contributed on helping how to fix it! thanks!

1 Like
repeat
	task.wait()
until #game.Players:GetPlayers() >= 2
1 Like