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