I would like to know how to save player's KO's and WO's in the leaderboards so that it appears the next time they come?
Thank you!
I would like to know how to save player's KO's and WO's in the leaderboards so that it appears the next time they come?
Thank you!
Do you know how to make the leaderboard? Do you know how your leaderboard works? If so then this should work.
I will give you a simple .Touched script that you can play around and soon put it into a Gui or maybe even a .Chatted format. Whatever you'd like.
function OnTouchSave(plr) -- Plr is the part that hit the brick. I named it plr (short for player) knowing it is for players only.
if plr.Parent:findFirstChild("Humanoid") ~= nil then
Player = game.Players:GetPlayerFromCharacter(plr.Parent)
Player:WaitForDataReady()
if Player.leaderstats.KOs ~= 0 then -- So you don't save a nil number. That would be stupid.
Player:SaveNumber("KOs", Player.leaderstats.KOs.Value)
end
end
end
script.Parent.Touched:connect(OnTouchSave)
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
Hmm looks like my script derped.
Fixed it. Just replace "KOs" with whatever your leaderstats are called. Copy paste the part where I check to see if KOs is not equal to nil and you can make one for WOs too. If you're using linked leaderboard I don't recommend this. I'd look into Data Persistence a little more.
Just a side note. You'll need to be in the game (NOT IN EDIT MODE) for this to work.
Where do I put the script? Workspace? I did, but it didn't work.
Uh. No I said it is a .Touched script. You put it in a brick and put the brick in workspace.