Good day, I am currently working on an aim script where the character is anchored so as to make it stay in place, and to make the character face where the mouse is facing.
When I equip the tool, that’s where I anchor the character and where the aiming takes place. When I unequip it, it stops aiming and unanchors the character.
But the problem is that after unanchoring the character, the jump somehow still continues? I don’t want this, I just want the character to fall after “aiming”.
Here is the video of my problem and the code snippet:
https://streamable.com/zpjv6r
Inside the local script:
local player = game.Players.LocalPlayer
local isHolding = false
local mouseConnection
tool.Equipped:Connect(function()
isHolding = true
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")
--Anchor the character and add the mouse event.
rootPart.Anchored = true
mouseConnection = mouse.Move:Connect(function()
if isHolding then
--Rotate the character.
rootPart.CFrame = CFrame.new(rootPart.Position, rootPart.Position + mouse.Hit.LookVector)
end
end)
end)
tool.Unequipped:Connect(function()
isHolding = false
local character = player.Character or player.CharacterAdded:Wait()
local rootPart = character:WaitForChild("HumanoidRootPart")
--Unanchor the character and disconnect the event.
rootPart.Anchored = false
mouseConnection:Disconnect()
end)
Anyone have any fixes for this? Again, I just want the character to fall right after he unequips the tool.