I’m sure this is going to look extremely easy to someone, so I’m sure they can help. I am a Roblox builder, not a scripter. I am trying to make the loading screen say “Welcome to the game, (Player Name)”. This is what I have so far, but I’m not totally sure how to continue.
local playerservice = game:GetService("Players")
local player = playerservice.LocalPlayer
local loadingtext = script.Parent
Now quite honestly, when I look through the DevForum, I can barely understand half of the terms used when referring to coding, so please explain in a way that a non-scripter would be able to understand. Thanks!
local playerservice = game:GetService("Players")
local player = playerservice.LocalPlayer
local playername = player.Name
local loadingtext = script.Parent
loadingtext.Text = "Welcome to the game, "..playername
Well, let me just give you some nice tips for the future.
Instead of
local playerservice = game:GetService("Players")
local player = playerservice.LocalPlayer
-- you can just do
local player = game.Players.LocalPlayer
Then do put strings together you use . . so
print("hi " .. "peter") -- hi peter
With this said, your script should be
local player = game.Players.LocalPlayer
script.Parent.Text = "Welcome to the game, " .. player.Name -- player.Name is a string, so it'll sum the strings
Ok, if you want a text to say, “Welcome, (your name here)! You would do this,
Add a localscript into a Textlabel GUI and add your code into that localscript.
Still isn’t working? That’s because you forgot to add the path to set the text to, your just setting the parent to that text. This is what you need to do
local loadingtext = script.Parent.Text
Replace the loading text line with this one and BAM! It should work!
Let me know if you get any errors or anything else I could help with! : )
local loadingtext = script.Parent.Text
this will just assign the script.Parent.Text’s property value to the variable. So if the text is “hello”, then loadingtext will be hello. If you do loadingtext = “hi” then it will change the variable, not the text itself