game:GetService("ReplicatedStorage").Coin.OnServerEvent:Connect(function(player)
--[[ local player = Players.LocalPlayer
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10
--assuming you already created a leaderboard , with currency Coins ]]
end)
I ain’t sure why but it doesn’t seem to work. The event fires properly but the value isn’t added to the player’s leaderboard. (no errors in the output)
it works, you need to create a leaderboard first and insert an int value called Coins to the player, the leaderboard folder should be named leaderstats
edit: show us your scripts and where they are placed,
local character = script.Parent
local player = game.Players.LocalPlayer
local humanoid = character:WaitForChild("Humanoid")
humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
if humanoid.Jump == true then
print(player.Name.." just started jumping!")
local value = math.random(1,10)
if value == 10 then
print(player.Name.." got lucky, and won some coins!")
game.ReplicatedStorage.JumpCoin:FireServer()
-- Insert a remoteevent or a module function here for coins
end
else
print(player.Name.." just ended their jump.")
end
end)
It Basically should fire when the player jumps but a bit random.
Just a note because I didn’t (unless I missed it) see someone say it, you should never trust the client with anything. If you need to determine when to give the player coins, you should do the calculations on the server rather than on the client as the client can easily be exploited.