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

Why does my PlayerJoined script work in studio and not in-game?

Asked by 7 years ago
Edited 7 years ago

Hello,

For some reason, I don't know why, my script works in studio and not in-game. What my script does is it updates a TextLabel in a GUI every time a player joins to the name of the player that just joined.

Attempted Solutions: Restarting Roblox + Roblox Studio, triple checking script for silly typo errors.

Below is a screenshot of where things are in StarterGui and a copy of the code in the script. There is only one script.

Screenshot: https://gyazo.com/8a6229bec94af32760075564d0ac0ed7

Code:

wait(3) --This wait(3) is here so the game can load in before the script fires.

local Players = game:GetService('Players')
local Text = script.Parent.Text
local PlayerText = script.Parent.PlayerText
local Line = script.Parent.Line

function onPlayerAdded(player)
        PlayerText.Text = player.Name
        Text.Visible = true
        Line.Visible = true
        PlayerText.Visible = true
        wait(5)
        Text.Visible = false
        Line.Visible = false
        PlayerText.Visible = false
        wait(1)
end

Players.PlayerAdded:connect(onPlayerAdded)

for _,player in pairs(Players:GetPlayers()) do
    onPlayerAdded(player)
end

I would very appreciate a response to my problem, and I wish everyone who reads this a good day!

Answer this question