Hi Everyone!
I was making this code for my game of tag, which attempts to detect a person in-game who reset, to respawn them back into the map. I use this code below to fire a message to the client:
for i = 1, #playersinround do
player = playersinround[i]
print(player) -- prints "Git_Good445"
print(playersinround[1]) -- prints "Git_Good445"
game.ReplicatedStorage.MapSpawns:FireClient(player, MapSpawns, playersinround)
end
(playersinround is a table containing the players of the people who are in the round, and its important to note that the containments of the MapSpawns table are regular parts)
Then, i use this code below to fire a message to a different script than the one before.
game.ReplicatedStorage.MapSpawns.OnClientEvent:Connect(function(MapSpawns, playersinround)
print(playersinround[1]) -- prints "Git_Good445"
game.ReplicatedStorage.MapSpawns:FireServer(MapSpawns, playersinround)
end)
Finnaly, the message goes to this code in a different server script, that the 1st one.
CurrentStatus = game.ReplicatedStorage.CurrentStatus
game.ReplicatedStorage.MapSpawns.OnServerEvent:Connect(function(mapspawns, PIR)
MapSpawns = mapspawns
playersinround = PIR
print(playersinround[1].Name) -- prints "Part"
end)
game:GetService("Players").PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
print(plr.Name .. " has died!") -- prints
plr.CharacterAdded:Connect(function()
print(plr.Name .. " has respawned") -- prints
if CurrentStatus.Value == "Round" then
print("Round In Progress") -- prints
print(playersinround[1].Name) -- prints "Part"
print(#playersinround) -- prints "9", another problem
for i = 1, #playersinround do
print("Is " .. plr.Name .. " in the round?")
local playerName = playersinround[i].Name
print("Person in round is " .. playerName) -- prints "Person in round is Part"
if playerName == character.Name then
print(plr.Name .. " is in the round") -- doesnt print
if character:FindFirstChild("HumanoidRootPart") then
print("HumanoidRootPart Found") -- doesnt print
local spawnNumber = math.random(1, #MapSpawns)
character.HumanoidRootPart.CFrame = MapSpawns[spawnNumber].CFrame + Vector3.new(0,7,0)
end
end
end
end
end)
end)
end)
end)
For some reason, when it gets to the other server script, the player is misinterpreted for a regular part. Why is it doing that?
Any help is appreciated :)
