Here, plr always returns a nil value. What am I doing wrong and how should it look instead?
username = script.Parent.Parent.TextBox.Text
plr = game.Players:FindFirstChild(username)
while true do
print(plr.Name)
wait(10)
end
Here, plr always returns a nil value. What am I doing wrong and how should it look instead?
username = script.Parent.Parent.TextBox.Text
plr = game.Players:FindFirstChild(username)
while true do
print(plr.Name)
wait(10)
end
Lines 1 and 2 run once. The initial values don't change, because you don't tell them to. You can remedy this easily:
while true do
local username = script.Parent.Parent.TextBox.Text --// Use local variables
local plr = game.Players:FindFirstChild(username)
print(plr.Name)
wait(10)
end
However, you'd probably be able to do whatever you plan to do here using the Changed event. I'd recommend reading up on it.
Hope this helped.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Great, thank you! :)