Why is my touch event local script firing for everyone else

For some reason, when I fire the touch event on 1 client it fires on the other one aswell anyone knows why? I can tell its happening cause of my print() function being fired on both clients when the other one didn’t touch the part yet.

Here’s the script:

local Plots = workspace.Plots
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local function IsEmpty(plot)
	if plot.Owner.Value == "NoOwner" then
		return true
	else
		return false
	end
end

for _, plot in pairs(Plots:GetChildren()) do
	local TouchConnection
	if IsEmpty(plot) then
		for _, indicator in pairs(plot.EmptyIndicator:GetDescendants()) do
			if indicator:IsA("BasePart") and indicator.Name ~= "DetectionZone" then
				indicator.Transparency = 0
			elseif indicator:IsA("BillboardGui") then
				indicator.Enabled = true
			elseif indicator.Name == "DetectionZone" then
				local Touched = false
				TouchConnection = indicator.Touched:Connect(function(hit)
					if Touched == false then
						if hit.Parent then
							if hit.Parent:FindFirstChild("Humanoid") then
								print(hit.Name.." has touched")
								Touched = true
							end
						end
					end
				end)
			end
		end
	elseif not IsEmpty(plot) then
		for _, indicator in pairs(plot.EmptyIndicator:GetDescendants()) do
			if TouchConnection then
				TouchConnection:Disconnect()
			end
			if indicator:IsA("BasePart") and indicator.Name ~= "DetectionZone" then
				indicator.Transparency = 1
			elseif indicator:IsA("BillboardGui") then
				indicator.Enabled = false
			end
		end
	end
end

Are you saying that when Player1 touches the part and sees the print “Player1 has touched”, that Player2 also sees the same print statement, or do the see “Player2 has touched”?

I made a brief tutorial about this issue.

To summarise: you aren’t checking if the character who touched the part (if one exists) belongs to the LocalPlayer. Touched will still fire for all clients because a part that is visible to them physically intersected with the part that has the Touched event so you need to confirm that the touching part belongs to the LocalPlayer’s Character.

This popped up exactly when it started happening to me :thinking:

Thank you so much, i already found the problem and that’s how i fixed it. This method works, i checked if the character that touched the part is equal to the local player using GetPlayerFromCharacter() function.