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

Not working in game?

Asked by 8 years ago

Basically, I want this StarterGui to pop up when a certain player is in the playerlist, in this case, my name. The script works perfectly fine on Studio but for some reason, when I try it in game, it doesn't even show. From what I can see, no errors are present. The Gui is in the StarterGui tab and the script (LocalScript) is running in the StarterPack tab (as this was the only place where it worked on Studio). Any help resolving this will be appreciated.

if game.Players.LocalPlayer.Name == "toughjohncena1256" or "Player1"
    then
game.StarterGui.cars.ScrollingFrame.Visible = true
game.StarterGui.cars.TEXT1.Visible = true
game.StarterGui.cars.TEXT2.Visible = true
game.StarterGui.cars.TEXT3.Visible = true
game.StarterGui.cars.TEXT4.Visible = true
end




1 answer

Log in to vote
1
Answered by 8 years ago

The reason your code is not working is because you're accessing starterGUI instead of the players GUI. Also, you will want to wait for the Player's GUI to load.

local plr = game.Players.LocalPlayer
plr:WaitForChild("PlayerGui")-- wait for GUI 
if plr.Name == "toughjohncena1256" or plr.Name == "Player1" then
    plr.PlayerGui.cars.ScrollingFrame.Visible = true
    plr.PlayerGui.cars.TEXT1.Visible = true
    plr.PlayerGui.cars.TEXT2.Visible = true
    plr.PlayerGui.cars.TEXT3.Visible = true
    plr.PlayerGui.cars.TEXT4.Visible = true
end

That should work. Good luck!

0
Thank you for your reply. It works when I play solo, but I cannot play the game as it is just a saved project on Studio. Whenever I try to transport it to another game, it doesn't even work when played solo. Any ideas? toughjohncena1256 57 — 8y
0
I've never had this problem so I don't think I can help you but you should make sure you publish your game to Roblox. But that's all I've got. Like I said, Im not the person to be asking such a question. User#11440 120 — 8y
0
I've published it, and it works fine. Only trouble is I'm trying to place it into somewhere which already has stuff there, so I can't publish it to that place, otherwise I'll lose everything already there. However, thank you for your help. toughjohncena1256 57 — 8y
0
Nevermind, got it to work. Thanks. :) toughjohncena1256 57 — 8y
0
<3 User#11440 120 — 8y
Ad

Answer this question