How to make individual value to each player

Hello! Today me wanted to update my game currency but, i found a problem
When a player gets currency then all players gets it instead Player what collected it.
Example: Player 1 collected daily reward then script gived him 7 coins but all players gets 7 coins. And if a player purshace a 6 coins product then all will lose 6 coins.
Im want to make value to be individual to each player but im dont know how to make it.

3 Likes

make an intvalue for each individual player player and do it from there

1 Like

There are a few ways you could go about this, some better than others but ultimately all just as good. The best way I’d recommend is using some sort of player data module, which stores all of the players data within a module which can be distributed to other scripts as to read data.

Another way would be to use folders for players and then have values in them, as so you can simply retrieve it. This method is a little more restricting but it works.

Ok but where i need to place the folder?
изображение_2021-09-18_162232
Originally folder was in workspace and value is one for all players

2 Likes

Personally, if I need to access it on the client and server I would put it in ReplicatedStorage or somewhere similar, however if I only needed the server to access the values then it can be put into ServerStorage.

Using leaderstats, you can make a player leaderboard and you can store values there, like currency for example. image

game.Players.PlayerAdded:Connect(function(plr)

local leaderstats = Instance.new("Folder")

leaderstats.Name = "leaderstats"

local cash = Instance.new("IntValue")

cash.Name = "Cash" -- change to what ever you want for the name of the currency.

cash.Parent = leaderstats

leaderstats.Parent = plr

end)

function SetCurrency(player, value)

if player.leaderstats then

player.leaderstats.Cash.Value = value -- if you change the name of the currency than change the Cash part to the new name.

end

end
3 Likes

Hey there, this is similiar to what ive did in the past but you can try this:
You can create a new instance value for each individual’s model, which I dont feel like explaing but you can try this:


Ignore the crossed out red stuff they are irrelevant
You can put this is startcharacterscripts and each individual will get their own amount of coins
if you don’t like that idea maybe this:
image
You make a script for when every individual player joins, the game makes a folder in the game.players sectiong and make a number value inside it
(leaderstats)

1 Like