I am making stats and I want the owners to have a certain amount of cash. I am having trouble at the bottom of this script. Thanks :)
game.Players.PlayerAdded:connect(function(plr) --// Stats //-- local folder = Instance.new("Folder",plr) folder.Name = "leaderstats" local stat3 = Instance.new("BoolValue",plr) stat3.Name = "HasHome?" stat3.Value = false local stat1 = Instance.new("StringValue",folder) stat1.Name = "Cash" stat1.Value = 1000 local stat2 = Instance.new("StringValue",folder) stat2.Name = "Class" stat2.Value = "Low Class" --// Owner's stats //-- if plr.Name == "PlayersName" or "PlayersName2" or "PlayersName3" then game.Players.PlayersName.leaderstats.Cash = 9999999 game.Players.PlayersName2.leaderstats.Cash = 9999999 game.Players.PlayersName3.leaderstats.Cash = 9999999 end end)
As KingLoneCat pointed out, you should use IntValue
or NumberValue
to store integers/numbers respectively (not StringValue
).
What do you think or
does?
or
combines to conditions together. For example,
badDayForPicnic = isCold or isRaining
It does not combine values:
fruit = "blueberry" or "strawberry" print(fruit) --> blueberry
You do not get some "multi-value" which you can compare plr.Name
against all of the strings at once.
You must be explicit and repeat your conditions:
if plr.Name == "One" or plr.Name == "Two" or plr.Name == "Three" then
The logic behind lines 21--25 makes little sense.
When a new player joins, you check their name.
If the new player is a VIP,
You set every VIP's money to a big number.
This is clearly not a reasonable thing to do
plr
who is joining not involved in this code?game.Players.VIP2
doesn't exist!Just modify stat1
:
stat1.Value = 999999
(You had also forgotten your .Value
on the cashes)
Problem:
You are using a StringValue
for integers which works however, you forgot the quotation marks or however you make a string.
Solution:
Either make the Cash a IntValue
by doing the following:
local stat1 = Instance.new("IntValue", folder) stat1.Name = "Cash" stat1.Value = 1000
OR..
You can add quotation marks to the StringValue
s 'cause that's what marks StringValue
s... Something of this sort:
stats1.Value = "1000" game.Players.PlayersName.leaderstats.Cash = "99999999"
I hope I helped and thank you for reading this answer.
~~ KingLoneCat