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 3 months 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 2296 — 3mo
0
things[i].Parent.Humanoid:UnequipTools() Worthy0ne 2 — 3mo
0
I tryed useing the UnequipTools function but it still seems not to work. Worthy0ne 2 — 3mo

Hi.

Looks like you're using an ad blocker.

That's fine...

No, it really is.

Just, I mean, we put a lot of work into this site, you know?

It would be really really appreciated if you would turn off your ad blocker for our website...

We tried really hard to make our ads as unobtrusive as possible.

If you really hate ads, would you consider a $2 donation via Patreon?

Here's the link.

We love you. We hope you love us too.

.

..

...

Now back to your regularly scheduled Scripting Helpers....

...

..

.

1 answer

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



Ad