I have 2 scripts, one is for destroying a part locally, the other is to increment a value on the server side.
Script using local run context:
local players = game:GetService("Players")
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = players:GetPlayerFromCharacter(hit.Parent)
script.Disabled = true
game.ReplicatedStorage.Events.ClockDestroy:FireServer(1)
script.Parent.Noise:Play()
task.wait(1)
script.Parent.Parent:Destroy()
end
end)
Script using server run context:
game.ReplicatedStorage.Events.ClockDestroy.OnServerEvent:Connect(function(plr, Number)
if Number == 1 then
plr:WaitForChild("PlrServerData").DualClocks.Value += 1
end
end)
The issue: When a player collects one of the clocks, it removes it from all of the clients.
What i want to achieve: Make it so the player can get a clock, remove it on the client side, and increment their clock value by 1.
