I am using 2 remote events to send the value of a string value to the server, then back to all clients. The script that receives the remote event that goes back to the clients checks if the value of the string value is the same as another string/value. it determines wether that part of the code is fit to go on, but apparently the value I send over the events is nil. in the same way, with the same scripting, I have sent values just like that without them turning nil, so I am very confused.
This is the part of the code that sends the remote event
game.ReplicatedStorage.JoinPlayerToClient.OnClientEvent:Connect(function(Player, Owner)
if Player.Name == game.Players.LocalPlayer.Name then
script.Parent.Parent.Players.HostPlayer.Player.Value = Owner
end
end)
script.Parent.MouseButton1Click:Connect(function()
local Owner = script.Parent.Parent.Players.HostPlayer.Player.Value
print(script.Parent.Parent.Players.HostPlayer.Player.Value)
game.ReplicatedStorage.RemovePlayerToServer:FireServer(Owner)
end)
This is the code that passes it back to the client
game.ReplicatedStorage.RemovePlayerToServer.OnServerEvent:Connect(function(player: Player, Owner)
game.ReplicatedStorage.RemovePlayerToClient:FireClient(player, Owner)
end)
This is the code that receives the event passing to the client
game.ReplicatedStorage.RemovePlayerToClient.OnClientEvent:Connect(function(player, Owner)
print(script.Parent.HostPlayer.Player.Value)
print(Owner)
if Owner == script.Parent.HostPlayer.Player.Value then
if script.Parent:FindFirstChild("GeustPlayer1") then
GeustPlayer1 = script.Parent:FindFirstChild("GeustPlayer1")
end
if script.Parent:FindFirstChild("GeustPlayer2") then
GeustPlayer2 = script.Parent:FindFirstChild("GeustPlayer2")
end
if script.Parent:FindFirstChild("GeustPlayer3") then
GeustPlayer3 = script.Parent:FindFirstChild("GeustPlayer3")
end
if GeustPlayer1.Player.Value == player.Name then
GeustPlayer1.TextLabel.Text = GeustPlayer2.TextLabel.Text
GeustPlayer1.ImageLabel.Image = GeustPlayer2.ImageLabel.Image
GeustPlayer1.Player.Value = GeustPlayer2.Player.Value
GeustPlayer2.TextLabel.Text = GeustPlayer3.TextLabel.Text
GeustPlayer2.ImageLabel.Image = GeustPlayer3.ImageLabel.Image
GeustPlayer2.Player.Value = GeustPlayer3.Player.Value
GeustPlayer3:Destroy()
elseif GeustPlayer2.Player.Value == player.Name then
GeustPlayer2.TextLabel.Text = GeustPlayer3.TextLabel.Text
GeustPlayer2.ImageLabel.Image = GeustPlayer3.ImageLabel.Image
GeustPlayer2.Player.Value = GeustPlayer3.Player.Value
GeustPlayer3:Destroy()
elseif GeustPlayer3.Player.Value == player.Name then
GeustPlayer3:Destroy()
end
if player.Name == game.Players.LocalPlayer.Name then
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.LobbyListUi.Visible = true
end
end
end)
Just to specify, some unnecessary code has been removed, only the essentials are present, incase you see something that doesn’t make sense.