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

Player dos not hold tool after it is equipped for a 2nd time. How can I fix this?

Asked by 8 years ago

Hi, Am trying to make an inventory gui with button to activate different weapons. Basically when a player presses the button, the weapon in ReplicatedStorage is cloned and placed into the Player's Character. This only works once. When the player presses the next button it removes all tools it has and then clones and places the next identical weapon inside him, but this dos not work anymore(even if I reset). When I try to equip the weapon again, it is placed into the character, but it appears in the middle of the map and falls through until it is destroyed. Below is some of the code inside the inventory gui when the button is pressed. If anyone has had this problem or have any suggestions, I would appreciate the help :)

01--Removes all tools from player
02local things = Player.Character:GetChildren()
03for i=1, #things do
04    if things[i]:IsA("Tool") then
05        things[i].Parent = Player.Backpack
06    end
07end
08local weapons = Player.Backpack:GetChildren()
09for i=1, #weapons do
10    weapons[i]:Remove()
11end
12 
13-- places weapon into Character
14local clone = script.Parent.ScrollingFrame.Inv2.Weapon.Value:Clone()
15clone.Parent = Player.Character
16script.Parent.ScrollingFrame.Inv2.BackgroundTransparency = 1
0
Humanoid has a UnequipTools() function. RubenKan 3615 — 8y
0
things[i].Parent.Humanoid:UnequipTools() Worthy0ne 68 — 8y
0
I tryed useing the UnequipTools function but it still seems not to work. Worthy0ne 68 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Ok, I was making this a lot harder then it had to be. I found that if I just put all the weapons in the StarterPack instead of the Replicated Storage and then I just use the UnequipsTools() function and switch the tool's Parent from BackPack to the Player's Character. So for some reason I can not do this useing Replicated Storage ;C

Ad

Answer this question