Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you access leaderboard from a different script?

I already have a savable leaderboard. Its all good.

Now, I am making a daily reward system. It is working, but it won't reward the player.

Cash is not working.

This is the cash part of my leaderboard

local cash = Instance.new("IntValue",stats)
	cash.Name = "Cash" 

This is the daily reward script

local reward = possibleRewads[math.random(1,#possibleRewads)]
game.ReplicatedStorage.ShowDailyReward:FireClient(player,hourWait,reward)
			local connection
			connection = game.ReplicatedStorage.ClaimReward.OnServerEvent:Connect(function(triggeringPlayer)
				if triggeringPlayer == player then
					print("Reward Claimed")
					player.leaderstats.cash.Value = player.leaderstats.cash.Value + reward
					DataStore:SetAsync(player.UserId.."-dailyReward",os.time())
					connection:Disconnect()
				end
			end)

2 comments

0

How is player (not triggeringPlayer since that's given in the Remote) defined in the second script?

0

Thats it. its triggeringPlayer == player

1 answer

✓ Accepted answer

You wrote player.leaderstats.cash.Value but you named it Cash. If you inspect the output (F9), it should say something about that in the server output.

Also note that you need to disconnect the connection if the player leaves the game (in case they never claim the reward).

1 comment

0

Thank you! I didn't realize that. lol

This discussion is preserved as it was. New answers, comments, and votes are closed.