What do you want to achieve? make the player walk normally after unequipping the tool
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
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)
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)