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 7 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 :)

--Removes all tools from player
local things = Player.Character:GetChildren()
for i=1, #things do
    if things[i]:IsA("Tool") then
        things[i].Parent = Player.Backpack
    end
end
local weapons = Player.Backpack:GetChildren()
for i=1, #weapons do
    weapons[i]:Remove()
end

-- places weapon into Character
local clone = script.Parent.ScrollingFrame.Inv2.Weapon.Value:Clone()
clone.Parent = Player.Character
script.Parent.ScrollingFrame.Inv2.BackgroundTransparency = 1
0
Humanoid has a UnequipTools() function. RubenKan 3615 — 7y
0
things[i].Parent.Humanoid:UnequipTools() Worthy0ne 68 — 7y
0
I tryed useing the UnequipTools function but it still seems not to work. Worthy0ne 68 — 7y

1 answer

Log in to vote
0
Answered by 7 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