I am trying to code various player stat bars, and I made a function to calculate the percentage of stat health to max stat health, and then to apply it to the GUI bar size.
'playerstats' is a folder within Player that holds several stat IntValues. Here is my function:
function statChange(player, stat) for x in player.playerstats do if x.Name == stat then percent = x/maxstathealth -- percent is defined above as 'local percent', and 'local maxstathealth = 100' end end for x in screengui do -- I have various frames within screengui that are named after the stats if x.Name == stat then x.Size = UDim2.new(percent, 0, 1, 0) end end end
I get the error "Trying to call method on object of type: Folder
with incorrect arguments." on the second line:
for x in player.playerstats do
I'm not entirely sure what this means, or how to fix it. Thank you very much in advance!
you can't do that, if your trying to go through the children of player.leaderstats
then you'd have to do it like this: for _, item in pairs(player.leaderstats:GetChildren()) do