I’m trying to make it so a TextLabel will display a constantly changing IntValue, in this case it’s named HungerVal and it is a child of the Player.
I’m getting the error of:
invalid argument #3 (string expected, got Instance)
This is the script that is under the TextLabel
local text = script.Parent
local plr = game.Players.LocalPlayer
wait(1)
while true do
script.Parent.Text = plr.HungerVal -- where the error is
end
This is what the explorer looks like
Any help on this would be greatly appreciated
FamorBlox
(FamorBlox)
August 22, 2021, 3:03pm
#2
Probably you forgot to add .Value afther plr.HungerVal, and also i would suggest adding a wait() inside the while true loop
Hello. Please use plr.HungerVal.Value
(assuming it is a string value).
local text = script.Parent
local plr = game:GetService("Players").LocalPlayer
task.wait(1)
while true do
task.wait()
script.Parent.Text = plr.HungerVal
end
Add a .Value to plr.HungerVal if it is a value like @FamorBlox said. The loop will get exhausted because there is no wait. Also I recommend to use task.wait() instead of wait().
Hey developers,
We have just enabled a brand new library that you can use in your projects. The task library allows you to talk directly with our engine’s task scheduler to manage and schedule code. It features a number of new methods as well as some improvements to existing methods.
Details
task.spawn
Takes a thread or function and resumes it immediately through the engine’s scheduler. Additional arguments are passed to the thread or function being resumed.
void task.spawn(function | thread,…
1 Like
Also, I would suggest using the .Changed
method as it is much more efficient that updating a value frequently.
1 Like