I have recently came back on ROBLOX to script and the one thing I find to struggle with is RemoteEvents. I understand somewhat of the concept but what I want to seek an answer for is how can I transfer player information from one place to another.
Let me stretch it out a bit. If you go to my other topic I recently wrote, I asked on how I can make a certain GUI appear on a certain player. I want to use the same idea and add it something else.
If anyone doesn’t mind explaining how information, or in this case, a player’s name, can be transferred from one place to another.
Well, kind of yeah. I am trying to make a feature where if a player touches a certain part, a text from a billboard GUI gets changed into the player’s name.
local part = (Part)
part.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
--It's a player
local chr = hit.Parent
local plr = game.Players:GetPlayerFromCharacter(chr)
local textLabel = (textLabel in billboard gui)
textLabel.Text = plr.Name
end
end)
Edit: Unless you want the billboard gui text to be seen only by the player and nobody else
Then you would have to fire a remoteevent to the player.
Create a RemoteEvent in ReplicatedStorage(presumably in a folder), and name it something like “BillboardDetection”
Then, in a regular script, put this:
local part = (Part)
part.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
local chr = hit.Parent
local plr = game.Players:GetPlayerFromCharacter(chr)
local textLabel = (textLabel)
game.ReplicatedStorage.BillboardDetect:FireClient(plr,textLabel)
end
end)
Thank you for informing on my issue but I also do want to learn from this so I have a question. When I fire an event, what do I put in the parenthesis. Like the example given, why was the second argument in the regular script, textLabel and the first argument in the LocalScript, “textLabel”