hi. right now, i’m making a game that you could say is like slap battles. one of the “abilities” is called banhammer. it’s supposed to have a leap ability. it works using a bezier curve. problem is, once the player reaches point2 (the end point), it keeps moving backwards.
ability script:
local bezier_curve = require(game.ServerScriptService.modules.bezier_curve)
local knockback = require(game.ServerScriptService.modules.knockback)
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
local char = plr.Character
local hrp = char.HumanoidRootPart
if char:GetAttribute("stunned") then return end
script.Parent.Parent.canhit.Value = false
local ff = Instance.new("ForceField")
hrp.Anchored = true
ff.Visible = false
local anim = char.Humanoid.Animator:LoadAnimation(script.anim)
ff.Parent = char
anim:Play()
local part1 = Instance.new("Part")
part1.Transparency = 1
part1.Anchored = true
part1.CanCollide = false
part1.CanQuery = false
part1.CanTouch = false
part1.Position = hrp.Position
part1.Position = hrp.CFrame.LookVector + Vector3.new(0, 12, 6)
part1.Parent = workspace
local part2 = Instance.new("Part")
part2.Transparency = 1
part2.Anchored = true
part2.CanCollide = false
part2.CanQuery = false
part2.CanTouch = false
part2.Parent = workspace
part2.Position = hrp.Position
part2.Position = hrp.CFrame.LookVector + Vector3.new(0, 0, 12)
part2.Parent = workspace
bezier_curve(hrp, hrp.Position, part1.Position, part2.Position, 10)
if hrp:IsGrounded() == true then
anim:Stop()
hrp.Anchored = false
script.Parent.Parent.hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("ForceField") then return end
if hit.Parent:FindFirstChild("Humanoid") then
local hit_char = hit.Parent
local hit_hum = hit_char.Humanoid
hit_hum:TakeDamage(30)
knockback(60, 800000, 10, hit_char, char, 2)
end
end)
end
ff:Destroy()
anim:Stop()
hrp.Anchored = false
end)
bezier module:
local bezier_curve = {}
local function bezier_curve(part, start, curve, finish, TIME)
local function QuadraticBezier(t,p0,p1,p2)
return (1-t)^2*p0+2*(1-t)*t*p1+t^2*p2;
end
for t = 0,TIME,0.01 do
local TargetPosition = QuadraticBezier(t , start, curve, finish);
part.Position = TargetPosition;
task.wait(0.01)
end
return
end
return bezier_curve
please help me out
if you need a vid add me on discord and ill send you one (my user is xodouble)