Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Can't seem to find Humanoid?

Asked by 9 years ago

This will select a random player but it doesn't seem to be finding a Humanoid. The purpose of the script is to force equip a tool to a random player and it's not working and I'm not too sure why?

local players = game.Players:GetChildren()
local randomplayer = players[math.random(1, #players)]
randomplayer:WaitForChild("Humanoid")
randomplayer.Humanoid:EquipTool(game.ServerStorage.HotPotato)

2 answers

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

The Humanoid object is inside of the Player's Character, not inside the Player(:

Look for the humanoid inside of the Player's Character!

local players = game.Players:GetChildren()
local randomplayer = players[math.random(1, #players)]

--Search in character
randomplayer.Character:WaitForChild("Humanoid")
randomplayer.Character.Humanoid:EquipTool(game.ServerStorage.HotPotato)
0
Ohh, I should have known that haha, thank you! However, the tool isn't showing up in any players? bookerjohnson 30 — 9y
0
When a tool is equipped, it's in the Character. Look there. Goulstem 8144 — 9y
0
The tool just isn't showing up anywhere... It's called HotPotato and it's parented under ServerStorage, I just pasted in the code you gave me and it's not showing up anywhere and there's no output. bookerjohnson 30 — 9y
0
If you just Parent the tool into the character it works too Goulstem 8144 — 9y
View all comments (2 more)
0
Hm.. For some reason I'm having some extensive trouble. Can I just accept this as an answer and PM you on Roblox? bookerjohnson 30 — 9y
0
Yeah Goulstem 8144 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

The humanoid is inside the player's 3d model in Workspace, or it's Character.

cal players = game.Players:GetChildren()
local randomplayer = players[math.random(1, #players)]
randomplayer.Character:WaitForChild("Humanoid")
randomplayer.Character.Humanoid:EquipTool(game.ServerStorage.HotPotato)

Hope this helped!

0
This one worked for me, but how do I make it stay equipped no matter what the player does? bookerjohnson 30 — 9y
0
You could turn it into a while wait() loop after line 2. ChemicalHex 979 — 9y
0
I've already tried that and they're still able to unequip :( No output bookerjohnson 30 — 9y
0
OH.......Just look into the tool properties. I think it's called 'Droppable' or something. ChemicalHex 979 — 9y

Answer this question