this needs to be the server script:
script.Parent.ClickDetector.MouseClick:Connect(function(player)
game.ReplicatedStorage.event:FireClient(player)
game.ReplicatedStorage.event:Connect(function(player)
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1
end)
script.Parent:Destroy()
end)
local script:
game.ReplicatedStorage.event.OnClientEvent:Connect(function()
game.ReplicatedStorage.event:FireServer()
end)
alternate version since im not sure the scripts above are needed because i dont script with clickdetectors a lot
server script:
script.Parent.ClickDetector.MouseClick:Connect(function(player)
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1
script.Parent:Destroy()
end)
2 comments
does it give any errors? looking at this script makes me think that the LocalPlayer value doesnt know where its going to.
its because server scripts cant access the local player