Not quite sure why you have the ["2"] there, as F.2.Value should work just fine?
From my knowledge you only use the brackets when you are referring to a table.
In example:
local Table = {
["Value"] = 1,
["Noogin"] = 2,
}
print(Table["Noogin"])
That'd print "2".
But back to the script, this is what Caster was referring to:
local Dad = game.ServerStorage.PlayerData:WaitForChild("Dadithan", 20)
local F = Dad.Inventory
local Number = F:WaitForChild("2", 20)
function si()
if Number.Value == 1 then
Number.Value = 100
Number.Metal.Value = 14
Number.Wood.Value = 15
Number.Name = "40"
end
end
si()
I'd suggest learning tables as that's a more secure and efficient way of doing it, however if you feel that you prefer this method then by all means.
I'll give a example of what the script would look like if it used a table:
(Assuming that the "Number.Value" is representing "Money" and the Number.Name is representing "Age" as I have no idea what your doing with them).
local PlayerData = {
["Age"] = 0,
["Money"] = 0,
["Metal"] = 0,
["Wood"] = 0,
}
local function DoCheck()
if PlayerData["Money"] == 1 then
PlayerData["Money"] = 100
PlayerData["Metal"] = 14
PlayerData["Wood"] = 15
PlayerData["Age"] = 40
end
end
local function AddToData(Value, Count)
PlayerData[Value] = PlayerData[Value] + Count
end
AddToData("Money", 50)
PlayerData["Money"] = PlayerData["Money"] + 50
With this method you don't have to wait for anything as it's already loaded by the time it hits the function, plus (Low level) exploiters can't simply edit the value to add to a stat.
If this is unhelpful, just let me know and I'll try to correct it.
2 comments
F:WaitForChild('2')?Can I get a rewritten version of it? I'm not sure what youre suggesting