Server:
if tplrs > 0 then
local plrs = game.Teams.T:GetPlayers()
local random = plrs[math.random(1, #plrs)]
game.ReplicatedStorage.Events.EquipGun:FireClient(random.Name) --oops
end
Client:
game.ReplicatedStorage.Events.RequestGun.OnClientEvent:Connect(function(name)
if name == game.Players.LocalPlayer.Name then
print(“test”)
end
end)
Does it have something to do with my character respawning?
Only seeing half of the code here - can please you show the code that receives the FireClient call? Additionally, please clarify the type of script your code is in.
When using FireClient and passing a player, you are sending a request from the server to one client, telling that one client to do something. That player is accessed via game.Players.LocalPlayer on the client. FireClient and FireAllClients does not pass a player, or their name or anything. Nor do you need one, because you have game.Players.LocalPlayer (which will always be the player that you used in FireClient)
You just modified your code to show that you’re passing the name of the player. This won’t work. You need to pass the actual player instead, and the OnClientEvent doesn’t receive that player (because you have LocalPlayer)