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
local gun = script.Parent.Parent.Backpack:FindFirstChild(script.Value.Value) -- gun local plr = script.Parent.Parent local plrname = plr.Name wait(1) print(gun) -- to verify it works local player = game.Workspace:FindFirstChild(plrname) if player then if gun then player.Humanoid:EquipTool(plr.Backpack.gun) -- ERROR IS HERE end end
Try removing the plr.Backpack, if your not trying to find something in the backpack, why are you looking in the backpack?
local gun = script.Parent.Parent.Backpack:FindFirstChild(script.Value.Value) -- gun local plr = script.Parent.Parent local plrname = plr.Name wait(1) print(gun) -- to verify it works local player = game.Workspace:FindFirstChild(plrname) if player then if gun then player.Humanoid:EquipTool(gun) -- ERROR IS HERE end end
Player
object doesn’t have a Humanoid
, but the Character
Model
does.player.Character.Humanoid:EquipTool(gun)