script.Parent.ClickDetector.MouseClick:Connect(function() game.Players.LocalPlayer.leaderstats.Coins.Value = game.Players.LocalPlayer.leaderstats.Coins.Value + 1 script.Parent:Destroy() end)
This doesn't work, i had to change from MouseButton1Click to MouseClick because it didn't work, still doesn't work aswell.
this needs to be the server script:
script.Parent.ClickDetector.MouseClick:Connect(function(player) game.ReplicatedStorage.event:FireClient(player)--tells the server to which client it should tell info to game.ReplicatedStorage.event:Connect(function(player)--roblox automaticaly sends who fired the server, because of that the line below will work player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1 end) script.Parent:Destroy() end)
local script:
game.ReplicatedStorage.event.OnClientEvent:Connect(function()--recieves that the server sends info, here is means the server wants to know something game.ReplicatedStorage.event:FireServer()--we fire to the server to give it access to the local player 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)