I am trying to create a TextLabel that changes every 5 seconds. I have this code, but it doesn't work.
local player = game.Players:GetPlayerFromCharacter(part.Parent) —this is our gateway to getting the PlayerGui object.
local PlayerUI = player:WaitForChild(“PlayerGui”)
local txtLabel = PlayerUI[“Welcome_Text”].TextLabel
while x < 1 do
wait(5)
txtLabel.Text = “Welcome to The Shadow Realm!”
wait(5)
txtLabel.Text = “Warning: This game contains scenes that may be too scary for some roblox players”
end
I am getting an error message that says.
ServerScriptService.Script:2: attempt to index global 'part' (a nil value)
I don't know where to put my gui.
'part'anywhere in your code, that is, it isnil–hence the error that saysattempt to index global 'part' (a nil value). You will also run into the same issue with the variable'x'because it is undeclared. Also, where will your above code be placed, and will it be in aScriptorLocalScript? - Personagex=0bit. The code will be placed in a script, not a local script. - Rpergy