So I have made it so the LocalPlayer gets 3 values, the main one I am focusing on is "LastName"
So I made this script in a ServerScript for a belt that you can put on;
script.Parent.Text = game.Players.LocalPlayer.CharacterName.Value
This appears to not find the values value and put it on the text, I assume there is meant to be a different script solution as to this is a ServerScript and I have gotten reference on what to do from my LocalScripts that have the similar line of code.
If I need to clear anything up with confusion on what I am explaining please let me know.
You can use PlayerAdded
as an alternative to LocalPlayer if you're using a server script.
game.Players.PlayerAdded:Connect(function(plr) script.Parent.Text = plr:WaitForChild("CharacterName").Value end)
Or you can just use the plr.Name instead of the CharacterName to get the Player's name, unless if you are making something else.
Or, if the tag is a descendant of a player's character, then:
local Char = script.Parent.Parent.Parent -- // Assuming the TextLabel is a Child of a SurfaceGui or BillboardGui, then the Gui is a Child of the Character. local plr = game.Players:GetPlayerFromCharacter(Char) script.Parent.Text = plr:WaitForChild("CharacterName").Value
Hmm... think i understand what you're trying to do here. You're trying to get the players name for your server script to display it in your belt?
If so, I've written a little example on how you can use a RemoteEvent
hooked up in a LocalScript
inside the player and a server-side script that listens to that event...
Code:
ServerScript:
local Rs = game:GetService("ReplicatedStorage") local REvent = Rs.RemoteEvent REvent.OnServerEvent:Connect(function(player) print("Player[",player.Name,"] Has Called me!") end)
Local Script: (using a tool to activate this event!..)
local Rs = game:GetService("ReplicatedStorage") local REvent = Rs.RemoteEvent local Tool = script.Parent Tool.Activated:Connect(function() REvent:FireServer() end)
If you want to pass more than the player to your server side script you just add it like this:
ServerScript:
local Rs = game:GetService("ReplicatedStorage") local REvent = Rs.RemoteEvent REvent.OnServerEvent:Connect(function(player, Val1--[[,ETC...]]) print("Player[",player.Name,"] Has Called me! \n Val1 is [",Val1,"]") end)
Local Script: (using a tool to activate this event!..)
local Rs = game:GetService("ReplicatedStorage") local REvent = Rs.RemoteEvent local Tool = script.Parent Tool.Activated:Connect(function() REvent:FireServer("Test!"--[[,ETC...]]) end)
Hope this helps! :)