I have made two scripts, a server and local scripts.
In my server script I made a stringvalue and set the value to player.name, then sent it as a remote event to the client
In my local script it recieves a remote function and makes a text label and sets the text as player.name. Then it recieves the remote event that was sent from the server script, and clones that text label and puts the text as player.name.
However, when retrieving the player.name data, it breaks and sends out nil.
ServerScript:
ReplicatedStorage.MaxPlayers.OnServerInvoke = function(player)
local MaxPlayersValue = Instance.new("NumberValue")
MaxPlayersValue.Parent = MaxPlayersFolder
MaxPlayersValue.Value = 1
MaxPlayersValue.Name = player.Name .. " 's Server"
local PlrNames = Instance.new("StringValue")
PlrNames.Parent = script.PlrNames
PlrNames.Value = player.Name
PlrNames.Name = player.Name
ReplicatedStorage.JoinServers.JoinServerPlayer:FireAllClients(PlrNames)
if MaxPlayersValue then
return true
else
return false
end
end
Local script:
local Players = game:GetService("Players")
local PlayerNameText = script.Parent.PlayerNameText
game.ReplicatedStorage.CreateServers.CreateServerPlayer.OnClientEvent:Connect(function()
print("recieved")
PlayerNameText.Text = Players.LocalPlayer.Name
PlayerNameText:Destroy()
end)
game.ReplicatedStorage.JoinServers.JoinServerPlayer.OnClientEvent:Connect(function(plrname)
print(tostring(plrname))
local playerTextClone = PlayerNameText:Clone()
playerTextClone.Text = tostring(plrname)
playerTextClone.Parent = script.Parent
end)
game.ReplicatedStorage.CloseFunction.LeaveServer.OnClientEvent:Connect(function(player)
local PlayerTextClone = script.Parent:FindFirstChild(Players.LocalPlayer.Name)
PlayerTextClone:Destroy()
end)
Where is your ServerScript located? Your issue is probably because the PlrNames StringValue isn’t replicated, so trying to send it over turns it into nil. You parented it to the script, but depending on the script’s location it’s not replicating.
You’re not giving the StringValue enough time to replicate on top of that. I don’t see a need for StringValues anyways. Just send the player’s username directly
I am extremely familiar with the Roblox engine. I know it will fail to replicate. What I am saying is that in the event it would, not enough time is given to allow the instance to replicate—this is a factor to consider in the coming solution
This is also wrong. When you send an instance over a remote, it will prioritize replication if it wasn’t already available on the client. It will not happen if the instance is inherently non-replicable, or if the instance is outside of the streaming radius.
Guys stop the beefing, we have different opinons on topics, and someone’s topics may be more correct over anothers but we do not need to ramble over and over again.