Hello ! I was wondering how, in my script, I can get the value contained in the character, having the humanoid object.
1 | function changeDefault(part) |
2 | if part.Parent:FindFirstChild( "Humanoid" ).Parent.IsHuman then |
3 | local character = part.Parent:FindFirstChild( "Humanoid" ) |
4 | changeSky:FireClient(game.Players:GetPlayerFromCharacter(character.Parent), "Default" ) |
5 | end |
6 | end |
The error message is :
1 | ServerScriptService.Regions: 30 : attempt to index nil with 'Parent' |
So basically you can just check for the humanoid because the parent will always be a player as long as you have not added another humanoid yourself.
1 | function changeDefault(part) |
2 | local character = part.Parent:FindFirstChild( "Humanoid" ) |
3 | if character then |
4 | changeSky:FireClient(game.Players:GetPlayerFromCharacter(character.Parent), "Default" ) |
5 | end |
6 | end |