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

Random gun selector script doesnt equip my gun with hum:EquipTool()?

Asked by
Nozazxe 107
3 years ago

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.

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! sne_123456 439 — 3y
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 sne_123456 439 — 3y
0
Try parenting the WeaponClone to the player's backpack before equipping it appxritixn 2235 — 3y
0
Sne, when i use GetChildren i get an error, error getting length of value or something Nozazxe 107 — 3y

Answer this question