So I made a simpler post earlier but I guess it didn't answer my question, so I have this script that equips a weapon when you spawn, but the problem is it tries to find something called gun in the backpack but I want it to find the variable that's called gun
01 | local gun = script.Parent.Parent.Backpack:FindFirstChild(script.Value.Value) -- gun |
02 | local plr = script.Parent.Parent |
03 | local plrname = plr.Name |
04 |
05 |
06 | wait( 1 ) |
07 | print (gun) -- to verify it works |
08 | local player = game.Workspace:FindFirstChild(plrname) |
09 | if player then |
10 | if gun then |
11 | player.Humanoid:EquipTool(plr.Backpack.gun) -- ERROR IS HERE |
12 | end |
13 | end |
Try removing the plr.Backpack, if your not trying to find something in the backpack, why are you looking in the backpack?
01 | local gun = script.Parent.Parent.Backpack:FindFirstChild(script.Value.Value) -- gun |
02 | local plr = script.Parent.Parent |
03 | local plrname = plr.Name |
04 |
05 |
06 | wait( 1 ) |
07 | print (gun) -- to verify it works |
08 | local player = game.Workspace:FindFirstChild(plrname) |
09 | if player then |
10 | if gun then |
11 | player.Humanoid:EquipTool(gun) -- ERROR IS HERE |
12 | end |
13 | end |
Player
object doesn’t have a Humanoid
, but the Character
Model
does.1 | player.Character.Humanoid:EquipTool(gun) |