I have a tool in starterpack and inside there a server script. My idea was to get the player from the backpack and then the character, but it errors saying nil or that it's not a valid member of DataModel. I found the player, but I can't use Player.CharacterAdded:Wait() or Player.Character for some reason.
1 | local tool = script.Parent |
2 | local player = script:FindFirstAncestorWhichIsA( "Player" ) |
3 | local character = player.Character or player.CharacterAdded:Wait() |
both player and character print right, but if I try to parent a model FROM the tool to the character it breaks saying "attempt to index nil with character"
(tool variable is the model)
1 | local tool = script.Parent |
2 | local player = script:FindFirstAncestorWhichIsA( "Player" ) |
3 | local character = player.Character or player.CharacterAdded:Wait() |
4 | print (player) |
5 | print (character) |
6 | tool.Parent = character |
prints but immediately after it says nil so...
1 | local tool = script.Parent |
2 | local player = script:FindFirstAncestorWhichIsA( "Player" ) |
3 | local character = game.Workspace:FindFirstChild(player.Name) |