How to send a textlabel's text in the playergui through to a remote event

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    In my game i need to change a string value in the player to be the same as a textlabel in a shop displaying the items name.
  2. What is the issue? Include screenshots / videos if possible!
    I am able to change the value and such but the actual value is what it is in StarterGui and not in PlayerGui, even though I sent a parameter of the text that was defined as PlayerGui.ShopGui.NameTag.Text.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I couldn’t find an existing answer as to why this is happening, so I decided to post instead.

Local Script:

local text = player.PlayerGui.NewStarterShopButtons:FindFirstChild("Nametag").Text

script.Parent.Activated:Connect(function()
	print(text) -- prints StarterGui TextLabel Text
	replicatedStorage.Remotes.EquipCone:FireServer(text)
end)

Server Script:

replicatedStorage.Remotes.EquipCone.OnServerEvent:Connect(function(player, text)
	print(player, text) -- prints player and StarterGui textlabel text
	
end)

You’re only reading the text once at the top of the script - never detecting any changes. You must fire the new text along the remote.

local label = player.PlayerGui.NewStarterShopButtons:FindFirstChild("Nametag")

script.Parent.Activated:Connect(function()
    local text = label.Text
	print(text) -- prints StarterGui TextLabel Text
	replicatedStorage.Remotes.EquipCone:FireServer(text)
end)
1 Like

I think your issue is that text will always be the nametag’s initial text value. Instead of sending the text value set a variable called NameTag = player.PlayerGui.NewStarterShopButtons:FindFirstChild(“Nametag”). THEN when you fire the server put in FireServer(NameTag.Text)

1 Like

Thank you, just figured this out and went to update this post. That makes a lot more sense with your explanation. Thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.