PlayerGui doesn't wanna show up when I call it to >: | ( For All players )

Hello! So Im trying to make a Elimination game, Ok neverminded by now you get the point if you saw my last post.... Lastly x2 considering my script STILL DOESNT WANT TO WORK WITH ME >:( Basically, Im trying to make it so that a Text will show, It will explain to the players how to play the game, when Its done the baseplate will start to shrink, when theirs one more player in the game then, the text will pop back up explaining that they won and then their supposed to get a badge ( when I have the robux to make it ) and then they will get kicked from the game! ( or teleported to a sequel if I do end up having people liking the game! )

Here is the Script

-- Defining Variables
local TutorialText = game.StarterGui.ScreenGui.TutorialText
local BaseplateStrinkScript = game.Workspace.Baseplate.Script
local kickHandlerScript = game.ServerScriptService.KickHandler
local playersInServer = #game.Players:GetPlayers()

local PlayerGui = game:GetService("PlayerGui")

-- First Line Of Code
BaseplateStrinkScript.Disabled = true
kickHandlerScript.Disabled = true

-- Game Startup

local function StartTheGame()
	kickHandlerScript.Disabled = false
	wait(5)
	PlayerGui.TutorialText.Visible = true
	wait(4)
	PlayerGui.TutorialText.Text = "In this game, Players must use the cars and Knock eachother off the Baseplate!"
	wait(7)
	PlayerGui.TutorialText.Text = "The Baseplate Will Strink Slowly so make sure you dont fall!"
	wait(7)
	PlayerGui.TutorialText.Text = "The Last player Standing Wins!"
	wait(5)
	PlayerGui.TutorialText.Text = "Goodluck, Players!"
	wait(5)
	PlayerGui.TutorialText.Visible = false
	BaseplateStrinkScript.Disabled = false
end

-- Looking For The Winner
local function StopTheGameAWinnerHasBeenChosen()
	BaseplateStrinkScript.Disabled = true
	wait(5)
	PlayerGui.TutorialText.Visible = true
	PlayerGui.TutorialText.Text = "Great Job Player!"
	wait(4)
	PlayerGui.TutorialText.Text = "Looks Like you have Won the game!"
	wait(5)
	PlayerGui.TutorialText.Text = "Your now one of the Best Fighters In Robloxia!"
	wait(7)
	PlayerGui.TutorialText.Text = "You were truley a Bloxer, you Deserve This Medal!"
	wait(5)
	PlayerGui.TutorialText.Text = "Congrats and, Goodbye!"
end

game.Players.PlayerRemoving:Connect(function()
	if #game.Players:GetPlayers() == 1 then
		StopTheGameAWinnerHasBeenChosen()
	end
end)

game.Players.PlayerRemoving:Connect(function()
	if #game.Players:GetPlayers() == math.random(2,20) then -- Checks if the playerlist has 2 all of the way to 20 players.
		StartTheGame()
	end
end)

Here is the Error

  11:34:49.045  ServerScriptService.MainScript:36: attempt to index nil with 'TutorialText'  -  Server - MainScript:36
  11:34:49.045  Stack Begin  -  Studio
  11:34:49.045  Script 'ServerScriptService.MainScript', Line 36 - function StopTheGameAWinnerHasBeenChosen  -  Studio - MainScript:36
  11:34:49.045  Script 'ServerScriptService.MainScript', Line 50  -  Studio - MainScript:50
  11:34:49.046  Stack End  -  Studio
1 Like

Pretty sure there’s no service called PlayerGui.

1 Like

When I dont put that their then, for some reason, I get a syntax error with everything that has PlayerGui followed up by the Tutorial Text

What Else can I do for this to show up for all players?

You could use a RemoteEvent to change the text in each player’s PlayerGui.

No the text changes, the GUI wont show up for any player though

You’ll need to have a ScreenGui in StarterGui with a TextLabel parented to it. It looks like you’re currently trying to change the text property of a direct child of StarterGui.


Edit:

Here’s a thread where someone did something similar:

You have to get playerGui from the player since playerGui is a member of the player. PlayerGui Is not a service.

1 Like
local PlayerGui = game.LocalPlayer.PlayerGui

(or something that go find the player instead of LocalPlayer)

1 Like
  12:01:59.874  LocalPlayer is not a valid member of DataModel "Server"  -  Server - MainScript:7
  12:01:59.874  Stack Begin  -  Studio
  12:01:59.874  Script 'ServerScriptService.MainScript', Line 7  -  Studio - MainScript:7
  12:01:59.874  Stack End  -  Studio
  12:02:16.404   â–¶ Unable to load plugin icon. (x2)  -  Studio

Didn’t work

Its because its a server script

Because I said this:

2 Likes

You won’t ever be able to get this to work. If you try to index LocalPlayer, you’ll be obligated to use a LocalScript, which isn’t able to access ServerScriptService or ServerStorage.

And also, you better remake all of of this, because the code is bad. You should learn more about scripting, until you think you’re ready. Try not to make a game so early.

@rtvr56565 , the issue is that you forgot to index the Players folder:

game.Players.LocalPlayer -- The correct.
1 Like

You want to get the player somehow and get the playerGui member in them.
Example how to get player gui:

game.Players.PlayerAdded:Connect(function(player)
local playerGui = player:WaitForChild("PlayerGui")
end)

oh, yea i forget it, thanks to correct me :smiley:

  12:05:18.431  KickHandler is not a valid member of ServerScriptService "ServerScriptService"  -  Client - LocalScript:4
  12:05:18.433  Stack Begin  -  Studio
  12:05:18.433  Script 'Workspace.NubblyFry.LocalScript', Line 4  -  Studio - LocalScript:4
  12:05:18.434  Stack End  -  Studio
  12:05:21.971  0.5, 0.5  -  Server
  12:05:22.208  0.5, 0.5  -  Client
  12:05:37.364  Script timeout: exhausted allowed execution time  -  Server - KickHandler:2
  12:05:37.368  Stack Begin  -  Studio
  12:05:37.368  Script 'ServerScriptService.KickHandler', Line 2  -  Studio - KickHandler:2
  12:05:37.369  Stack End  -  Studio

The whole script breaks just if Im trying to get the GUI to show.

Have you tried doing what I’ve said yet? I think it might solve your issue.

1 Like

Early? Idk why people keep saying that I should learn more scripting, as long as a script works for me then, Im fine with it, Everyone scripts differently after all

I think I might of found a problem. Get tutorial text through the player gui. You have an error where where the script cannot find the tutorial text.

1 Like

It doesn’t work, because your defining a variable inside of that function you made, the variable will only be called inside of that function

You’re gonna have to identify the local player in order to get this…

local plr = game:GetService("Players").LocalPlayer
local PlayerGui = plr.PlayerGui

@StarJ3M

Then make it a global variable by not putting local.