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

How do I make a simple script which makes a TextLabel appear when the player joins?

Asked by 5 years ago

I'm a builder, so bare with me here. I have literally NO idea how to script WHATSOEVER. I can only begin to understand what "local" means in Roblox Lua. What I'm trying to say is, how do I make a TextLabel appear on the player's screen after they join? I figured it'd be simple, but I'm obviously doing it way wrong. I'm trying to make a story game with simple destination quests where you click doors and objects and whatnot to progress. I can't do that if I don't even know how to make some text appear.

So here's what I've written:

local yeet = script.Parent

function onPlayerEntered(player)
    repeat wait () until player.Character

    wait (4)

    yeet.TextTransparency = 0

end

game.Players.PlayerAdded:connect(onPlayerEntered)
onPlayerEntered(game.Players:WaitForChild("Player1"))

If it's confusing as to what I was trying to do, the LocalScript is inside the TextLabel, and the TextLabel inside a ScreenGui in StarterGui. I have the TextLabel's TextTransparency set to 1. I was hoping that upon joining of the player, the text would no longer be transparent after a few seconds. Pretty much everything I wrote was nonsense from tutorial videos and cut out lines of free modeled scripts. So, in conclusion, I have a long road ahead of me. I just need some reliable information.

I apologize if I look utterly stupid when I ask this question. I'm just really new to this, and as usual, Google/YouTube is not a reliable source when it comes to asking questions so simple. Apparently it prefers to give me super complex methods which have nothing to do with what I'm attempting. You all should expect me here quite often. Anyways, I appreciate any help I can get! Thanks in advance.

0
first........................................................................................................................................................................................................................................................................................................................................................................................................... LoganboyInCO 150 — 5y
1
ok, step 1: learn lua greatneil80 2647 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

To fix this, all you need to do is use a remote event, because the client cannot run the PlayerAdded event like this. When fired from the client, remote events tell the server to do something, and vice-versa. A tutorial is included at the bottom of this answer.

--Server Script located in ServerScriptService

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = Instance.new("RemoteEvent")
Remote.Parent = ReplicatedStorage

Players.PlayerAdded:Connect(function(plr)
   Remote:FireClient(plr,"") --you can send any data in the second argument
end)

--Local Script located in your Gui object

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("RemoteEvent")

Remote.OnClientEvent:Connect(function(args) --the data you sent
   wait(4)
   script.Parent.TextTransparency = 0
end)

Resources:

Remote Events

Accept and upvote if this helps!

Ad

Answer this question