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

UnequipTools unequips a tool but then equips it again?

Asked by 6 years ago

I have this portion of my script:

local player = hit.Parent --It's a character, not an actual player.
player:WaitForChild("Humanoid"):UnequipTools()
            wait(.1)

for i,v in pairs(game.Players:GetPlayerFromCharacter(player).Backpack:GetChildren()) do
                if v.ClassName == "Tool" then
                    v.Parent = player:WaitForChild("Saved_Weapons")
                end
            end

The problem here is that the script unequips all the tools in the character but for some reason the tool decides to come back to the character and not to the "Saved_Weapons" folder.

Why is this happening? Am I missing something?

Any help is appreciated!

Ty <3

0
You could try setting its parent in saved_weapons folder each time? or something like if not blah.Parent then or if ~= blah.Parent then. If you get my drift. (sorry im terrible at scripting lol) THEROBLOXAIN2 15 — 6y
0
That would not change anything ;C wilsonsilva007 373 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

It says that the Saved_Weapons folder is in the character, because player is a reference to the character, and when a tool is put into a roblox character it automatically equips the weapon (even in a object thats inside of the character).

So in order to fix this, try and moving the folder to another place besides the character.

0
If this was the answer, make sure to make this the answered question. HeComesAt_Night 116 — 6y
Ad

Answer this question