Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How use wait correctly?

Asked by 4 years ago
Edited 4 years ago

I have this script in ServerScriptServer, but when I join in game the script dont work. But if I take the "wait" I can see the label.

> wait(1.0)
> local sgp = Instance.new("TextLabel")
> sgp.Name = "sgp"
> sgp.Parent = game.StarterGui.ScreenGui
> sgp.BackgroundColor3 = Color3.new(1, 1, 1)
> sgp.BackgroundTransparency = 1
> sgp.Position = UDim2.new(0.286624193, 0, 0.45161289, 0)
> sgp.Size = UDim2.new(0, 200, 0, 50)
> sgp.Font = Enum.Font.SourceSans
> sgp.Text = "Where I am?"
> sgp.TextColor3 = Color3.new(255, 255, 255)
> sgp.TextSize = 31
> sgp.TextStrokeColor3 = Color3.new(1, 0, 0)

1 answer

Log in to vote
0
Answered by
uhSaxlra 181
4 years ago

What it is doing is putting "sgp" into Startergui, which is not part of the player. Also, there is no function, there is a player added function which I will use.

To insert into the player's gui, simply change sgp's Parent to this:

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
 local sgp = Instance.new("TextLabel") 
sgp.Name = "sgp" 
sgp.Parent = player.PlayerGui
sgp.BackgroundColor3 = Color3.new(1, 1, 1) 
sgp.BackgroundTransparency = 1 
sgp.Position = UDim2.new(0.286624193, 0, 0.45161289, 0) 
sgp.Size = UDim2.new(0, 200, 0, 50) 
sgp.Font = Enum.Font.SourceSans 
sgp.Text = "Where I am?" 
sgp.TextColor3 = Color3.new(255, 255, 255) 
sgp.TextSize = 31 
sgp.TextStrokeColor3 = Color3.new(1, 0, 0)
end)
end)
Ad

Answer this question