Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Force-Equipt not working?

This script was placed inside of the gun, and when I try to run it this error appears: 12:07:19.710 - Something unexpectedly tried to set the parent of Assault Rifle [30] to Player while trying to set the parent of Assault Rifle [30]. Current parent is Backpack. Any Ideas? Here is the full code:

local tool = script.Parent-- Tool
local player = script.Parent.Parent -- Player
player.Character.Humanoid:EquipTool(tool)
tool.CanBeDropped = false
function equipAgain()
    player.Character.Humanoid:EquipTool(tool)
end
tool.Unequipped:connect(equipAgain)

1 answer

To equip tool you can just move it into character model, because that's how standart tool equipping works. And your script also must wait untill player character loads in order to equip a tool.

local tool = script.Parent
local player = script.Parent.Parent.Parent
repeat wait() until player.Character --Wait until player model loads
tool.Parent = player.Character --Equipping tool
tool.CanBeDropped = false
function equipAgain()
	if tool.Parent == "Backpack" then
    		tool.Parent = player.Character
	end
end
tool.Parent.Changed:connect(equipAgain)

5 comments

0

I dont get the error, but it allows me to put away the tool, any ideas

0

I changed it, now it should equip a tool if parent changed to "Backpack"

0

Awesome Thanks!

0

If it helped you, please accept the answer ;)

0

It all of the suddent stopped working?

This discussion is preserved as it was. New answers, comments, and votes are closed.