Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does this script not find the player in workspace?

game.Players.PlayerAdded:Connect(function(player) 
	wait(2)
game.Workspace:FindFirstChild(player.Name):Destroy() 

end)

Alright, This should always work, It sees when a player joins, then takes one of the values under the player, The name and finds it in the workspace. The model always has the same name as the player. Yet it gives me the error "Attempt to index a nil value". even though it says "player" is the new child of game.Players. What is happening? Is it a new Roblox update?

1 answer

✓ Accepted answer

Here is an attempted fix of your code.

game.Players.PlayerAdded:Connect(function(player) 
    player.Parent:FindFirstChild("Humanoid")
    wait(2)
    game.Workspace[player.Name]:Destroy()
end)

1 comment

0

Yeah that works, apparently FindFirstChild doesnt work or something

This discussion is preserved as it was. New answers, comments, and votes are closed.