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

How Can I make the tool unequip part to work?


What's wrong with this script?~~~~~~~~~~~~~~~~~






local player = game.Players.LocalPlayer

repeat wait(1) until player.Character -- Waits until the player's character isn't nil.


script.Parent.Equipped:connect(function()
	script.Parent.Parent.Humanoid.HipHeight = -1.4
end)

script.Parent.Unequipped:connect(function()
	script.Parent.Parent.Humanoid.HipHeight = 0
end)

3 comments

0

fix your script block...

0

iM NEW

0

The first ~~~~~~~~~~~~~~~~~ needs to be above, the second below the script 

1 answer

Once you unequip the tool, it's parented to the Backpack, and you're using script.Parent to get the player's character so maybe that's why.

Btw, use Connect() instead of connect() as it's deprecated.

local plr = game:GetService("Players").LocalPlayer
local tool = script.Parent

if not plr.Character then plr.CharacterAdded:Wait() end -- Waits until the player's character isn't nil.

tool.Equipped:Connect(function()
	plr.Character:WaitForChild("Humanoid").HipHeight = -1.4
end)

tool.Unequipped:Connect(function()
	plr.Character:WaitForChild("Humanoid").HipHeight = 0
end)

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