I keep getting the error "Attempt to index upvalue 'class' (a string value)" and I'm not exactly sure why. I'm attempting to set a TextLabel's text to a StringValue's value that is stored under a folder named "Stats" under the player.
local player = game:GetService("Players").LocalPlayer
local mainFrame = script.Parent
local class = mainFrame.ClassName
local AP = mainFrame.Attackpower
local SP = mainFrame.Spellpower
local DF = mainFrame.Defense
local RST = mainFrame.Resist
game:GetService("UserInputService").InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.C then
if mainFrame.Visible == false then
class.Text = player.Stats.ClassName.Value
AP.Text = ("Attack: "..player.Stats.Attackpower.Value)
SP.Text = ("Spellpower: "..player.Stats.Spellpower.Value)
DF.Text = ("Defense: "..player.Stats.Defense.Value)
RST.Text = ("Resist: "..player.Stats.Resist.Value)
mainFrame.Visible = true
end
end
end)
What exactly am I doing wrong because I'm totally clueless on this issue.
I've tried changing line 13 to this:
script.Parent.ClassName.Text = player.Stats.Class.Value
But then I get, "Attempt to index field 'ClassName' (a string value)"
