Hi. So i made a random gun selector. It works, but when i added hum:EquipTool() it doesnt equip the tool, nor give me the gun. This MIGHT be because i disabled the backpack gui but it was only the gui, so i dont think so. Anyone know why?


game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local hum = character:WaitForChild("Humanoid")
		local items = {script.AK47, script.G18, script.TrenchShotgun}
		local ChosenWeapon = items[math.random(1,#items)]
		local WeaponClone = ChosenWeapon:Clone()
		local hum = character:WaitForChild("Humanoid")
		hum:EquipTool(WeaponClone)
	end)
end)


Server Script in server script service.

4 comments

0

Do you see any errors in the output? if not can you add print statements between sections of the code so we can locate where the error is happening? Thanks!

0

And also instead of putting items in a table, you can do local item = script.GetChildren. I say you should do this beacuse its much easier and it could be that values in the table are strings

0

Try parenting the WeaponClone to the player's backpack before equipping it

0

Sne, when i use GetChildren i get an error, error getting length of value or something