Ad
Log in to vote
0

Why does this script not find the player in workspace?

Asked by 2 years ago
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

Log in to vote
0
Answered by 2 years ago

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)
0
Yeah that works, apparently FindFirstChild doesnt work or something iiConstable_Subwayx 130 — 2y
Ad

Answer this question