Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

attempt to call field 'PlayerStats' (a userdata value) What does it mean?

What this is doing is going into ReplicatedStorage looking for the folder playerstats then finding the players allocated folder the issue is this

21:19:27.277 - Players.Player1.PlayerGui.Bank.Frame.LocalScript:46: attempt to call field 'PlayerStats' (a userdata value)
21:19:27.279 - Stack Begin
21:19:27.281 - Script 'Players.Player1.PlayerGui.Bank.Frame.LocalScript', Line 46
21:19:27.282 - Stack End

(This is the script)

while wait(.5) do
	script.Parent.BankBorder.Deposited.Text = ReplicatedStorage.PlayerStats(playername).leaderstats.CashHouse.Value --player.leaderstats.CashHouse.Value
end


I'm not sure how to get around this error could someone help?

Also if you need the entire script let me know.

1 answer

✓ Accepted answer

The error says what it means.

You attempted to call the field .PlayerStats, but PlayerStats is a userdata (object) not a function.

"call" means use as function, e.g., print() is calling print.

"field" means use ., so .foo is the field "foo"

"userdata" means "some kind of special object". All of the ROBLOX types like Instances, BrickColors, Vector3s, etc. are userdata.

It tells you the line, and you can clearly see you doing exactly what it's complaining about: eplicatedStorage.PlayerStats(playername).

PlayerStats is an object. You can't call it. Square braces, not parenthesis, means access the object with the given name:

.... = ReplicatedStorage.PlayersStats[playername].leaderstats.CashHouse.Value

This discussion is preserved as it was. New answers, comments, and votes are closed.