How can i reset player movement after unequipping the tool?

  1. What do you want to achieve? make the player walk normally after unequipping the tool

  2. What is the issue? the script cannot index the humanoid right after the player unequips the tool bcuz the player.Character is no longer the parent of the tool

  3. What solutions have you tried so far? i have no idea what to do

local tool = script.Parent

function changeMovement(walkspeed, jumpheight)
	local hum = tool.Parent:FindFirstChild('Humanoid') --this part is the problem
	
	hum.WalkSpeed = walkspeed
	hum.JumpHeight = jumpheight
end

tool.Equipped:Connect(function()
	changeMovement(0,0)
end)
tool.Unequipped:Connect(function() --this is also part of the problem
	changeMovement(16,5.2)
end)

tool.Activated:Connect(function()
	local hum = tool.Parent:FindFirstChild('Humanoid')
	
	changeMovement(16,15)
	tool:Destroy()
	task.wait(20)
	changeMovement(16,5.2)
end)
1 Like

save the character to a variable

local tool = script.Parent
local LastChar = nil

function changeMovement(walkspeed, jumpheight)
	local hum = LastChar:FindFirstChild('Humanoid') --this part is the problem

	hum.WalkSpeed = walkspeed
	hum.JumpHeight = jumpheight
end

tool.Equipped:Connect(function()
	LastChar = tool.Parent
	
	changeMovement(0,0)
end)
tool.Unequipped:Connect(function() --this is also part of the problem
	changeMovement(16,5.2)
end)

tool.Activated:Connect(function()
	local hum = tool.Parent:FindFirstChild('Humanoid')

	changeMovement(16,15)
	tool:Destroy()
	task.wait(20)
	changeMovement(16,5.2)
end)
2 Likes

You could try storing the last Humanoid that equipped the tool then when they Unequip it, you just set the last Humanoid’s properties

thanks for helping! it worked :))

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.