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

Equipt Tool| Giving odd error?

Asked by 8 years ago

Idea The goal of this code is to re give a player a tool every time they un equip the tool.
Problem The problem is every time the player puts down the tool, I get an error.
Error the error give in Something unexpectedly tried to set the parent of Pistol to Player1 while trying to set the parent of Pistol. Current parent is Backpack.
CODE:

local tool = script.Parent.Parent.Backpack.Pistol
local player = game.Players.LocalPlayer

player.Character.Humanoid:EquipTool(tool)
tool.CanBeDropped = false

function equipAgain()
    player.Character.Humanoid:EquipTool(tool)
end

tool.Unequipped:connect(equipAgain)

1
Make it wait for like .25 seconds or so. Both Roblox and your script are trying at the same time, thus the error! legobuildermaster 220 — 8y

Answer this question