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

How do I make a gui appear to a player?

Asked by 7 years ago
Edited 7 years ago

This game is a one player only game (Singleplayer). I made a cutscene with a Gui that has text. The script works in 'Test Mode' on the studio, But it doesn't work when I play the game in ROBLOX itself. I think that the problem is that I need to replace something else with LocalPlayer, But I am not sure. The script is :

game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = "Test Presents"
wait(8)
game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = "Test"
wait(3)
game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Position = UDim2.new(0.5, -250, 0.5, 200)
game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = "A new Test opened Test"
wait(20)
game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Text = "Wow, I am Test!"


When I play the game on ROBLOX (Not studio) it won't show the text or change the position (Unlike the studio, Where everything works fine) and it will keep the test as "Label" (The deafult text).

  • Thanks!

1 answer

Log in to vote
0
Answered by
Async_io 908 Moderation Voter
7 years ago

The reason why you aren't seeing the position change and the text as label is due to you either using an improper script, or not using WaitForChilds.

WaitForChild will wait until the selected object loads. If you try to do something without using this first, then you'll likely receive errors as the object does not exist.

Client and Server are different, in that the client is the computer/player that is player, and the server is what is holding the player and other players. A normal game works by the client communicating to the server, and tell the server what's happening on their side. The server then tells the other clients what happened, and will tell the specified client other information about the rest of the clients. If you've ever seen anything about it, FilteringEnabled severs the link from the Client info to the Server. You can only communicate to the server by using a RemoveEvent and you can't make parts or values on a client server. With FilteringEnabled, the server makes the information, and gives it to the clients, and completely ignores the information provided by a client, unless using a RemoteEvent.

LocalScripts and Scripts are two completely different things. They have different purposes and preform different tasks. I was first confused with them, until someone explained them to me. Imagine a house with a family. Say that the kid was supposed to do a backflip or take out the trash. You would use a LocalScript, as you are telling one object, the client, to do it. If you were to use a normal script to do it, then it would be like screaming at the entire house to do it.

Your script

First, I would make a localscript in the StarterGui

Second, I would open the script then I would define the player, or client, you can do this with local player = game.Players.LocalPlayer; however, you cannot preform this in a normal script.

Third, would add a variable for the location of the TextLabel. You could do this by using local textlabel = player.PlayerGui:WaitForChild('ScreenGui'):WaitForChild('TextLabel')

Fourth, I would do as you did for the rest of the script. Add all the moving and such.

local player = game.Players.LocalPlayer
local textlabel = player.PlayerGui:WaitForChild('ScreenGui'):WaitForChild('TextLabel')
textlabel.Text = "Test Presents"
wait(8)
textlabel.Text = "Test"
wait(3)
textlabel.Position = UDim2.new(0.5, -250, 0.5, 200)
textlabel.Text = "A new Test opened Test"
wait(20)
textlabel.Text = "Wow, I am Test!"

I hope this helps, if it does then please accept my answer.

Ad

Answer this question