Hi, I currently have a script that checks for the part you collided with (in this instance the part is ‘v’) then debounce’s and temporarily changes its transparency; removing it from view. The issue I’ve confronted is that the debounce and transparent-property change affects all players, my intention is for the touched part to be “removed” for that singular client.
-- LocalScript in StarterPlayerScripts
local sound = workspace.Coins:FindFirstChild("Sound")
local debounces = {}
for i,v in pairs(workspace.Coins:GetChildren()) do
if v:IsA('BasePart') then
v.Touched:Connect(function(Hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
if player then
if not debounces[v] then
debounces[v] = true
-- print(v)
sound:Play()
v.Transparency = 1
game.ReplicatedStorage.CoinGiver:FireServer()
wait(10)
v.Transparency = 0
debounces[v] = false
end
end
end)
end
end
-- excuse the indentation haha
My intention isn’t to destroy it, I temporarily change its transparency to “respawn” the part after x amount of time. Albeit, I could clone the part, however keeping the part in the workspace was just a preference.
Probably because the Touched event fires for both clients, so it would make both delete the part locally. Try to do it again, and check on the server if the part transparency changed.
The transparency isn’t changing on the server, so I believe you’re correct in that it’s firing for both clients. I tried to add a condition statement that checks if Hit.Parent == plr.Name, however it returns nothing. No errors.
local sound = workspace.Coins:FindFirstChild("Sound")
local debounces = {}
local plr = game:GetService("Players").LocalPlayer
for i,v in pairs(workspace.Coins:GetChildren()) do
if v:IsA('BasePart') then
v.Touched:Connect(function(Hit)
if Hit.Parent == plr.Name then
if not debounces[v] then
debounces[v] = true
print(v)
sound:Play()
v.Transparency = 1
game.ReplicatedStorage.CoinGiver:FireServer()
wait(10)
v.Transparency = 0
debounces[v] = false
end
end
end)
end
end