I made a simple pogo localscript for a tool, but for some reason, it sometimes glitches out and sends me forward a little bit or just straight up flings me
I have no idea of what could be causing this to be honest
Flings:
Throwing me slightly away:
My script:
local player = game.Players.LocalPlayer
local tool = script.Parent
local attachment = Instance.new("Attachment")
attachment.Parent = player.Character.HumanoidRootPart
local canclick = true
function Hitbox()
if not canclick then return end
canclick = false
local handle = tool.Handle
local handlePos = handle.Position
local hitbox = Instance.new("Part")
hitbox.Name = "Hitbox"
hitbox.Size = Vector3.new(4, 7, 4)
hitbox.Material = Enum.Material.ForceField
hitbox.CanCollide = false
hitbox.Massless = true
hitbox.Color = Color3.new(1, 0, 0.0156863)
hitbox.CFrame = CFrame.new(handlePos.X, handlePos.Y - 6, handlePos.Z)
hitbox.Parent = tool
local weld = Instance.new("Weld")
weld.Part0 = handle
weld.Part1 = hitbox
weld.C0 = handle.CFrame:ToObjectSpace(hitbox.CFrame)
weld.Parent = handle
hitbox.Touched:Connect(function(hit)
if hit.Parent == workspace.Spikes then
local Bounce = Instance.new("LinearVelocity")
Bounce.MaxForce = math.huge
Bounce.Parent = player.Character.HumanoidRootPart
Bounce.Attachment0 = player.Character.HumanoidRootPart.Attachment
Bounce.VectorVelocity = Vector3.new(0,40,0)
task.wait(0.1)
Bounce:Destroy()
end
end)
game:GetService("Debris"):AddItem(hitbox, 0.1)
task.delay(0.3, function()
canclick = true
end)
end
tool.Activated:Connect(Hitbox)