What do you want to achieve? So, i am trying to move a rock using the bezier curves to make a attack, but it is bugging my script, like, it is duplicating everything inside the function that i use the bezier curve, and it is delaying the animantion, as you can see in my script and the video, i dont have any iddea that what is happening.
local RP = game:GetService("ReplicatedStorage")
local rockFlipRemote = RP.remotes.rockflip
local ss = game:GetService("ServerStorage")
local modules = ss:WaitForChild("Modules")
local slow = require(modules:WaitForChild("slow"))
local runService = game:GetService("RunService")
local rockModule = require(modules:WaitForChild("RockModule"))
local utilities = require(modules:WaitForChild("particleEmitter"))
local hitbox = require(modules:WaitForChild("hitbox"))
local hitService = require(modules:WaitForChild("hitService"))
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Include
params.FilterDescendantsInstances = {workspace.map}
function lerp(t,a,b)
return a*(1-t) + b*t
end
function quadBezier(t,p0,p1,p2)
local l1 = lerp(t,p0,p1)
local l2 = lerp(t,p1,p2)
local quad = lerp(t,l1,l2)
return quad
end
function rockBezier(humanoidRootPart)
local rock = Instance.new("Part",workspace.fx)
rock.CFrame = humanoidRootPart.CFrame * CFrame.new(0,-6,12)
rock.Size = Vector3.new(3,3,3)
rock.Anchored = true
rock.CanQuery = false
rock.CanCollide = false
rock.CanTouch = false
rock.Name = "rockkkkkk"
local detect = workspace:Raycast(rock.Position + Vector3.new(0,5,0), Vector3.new(0,-10,0),params)
if detect then
rock.Material = detect.Material
rock.Color = detect.Instance.Color
else
rock.Material = "Concrete"
rock.Color = Color3.fromRGB(98,95,97)
end
local pointA = rock.Position
local pointC = rock.CFrame * CFrame.new(0,0,-24).Position
local pointB = rock.CFrame * CFrame.new(0,30,-12).Position
for i = 0,1,0.025 do
local cframe = quadBezier(i,pointA,pointB,pointC)
rock.Position = cframe
task.wait()
end
task.wait(1)
rock:Destroy()
end
rockFlipRemote.OnServerEvent:Connect(function(plr)
local character = plr.Character
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local hitbox = hitbox.new()
hitbox.Size = Vector3.new(8,8,8)
hitbox.CFrame = humanoidRootPart
hitbox.Offset = CFrame.new(0,4,-5)
hitbox.Visualizer = true
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=anim"
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
local rockThrowAnim = Instance.new("Animation")
rockThrowAnim.AnimationId = "http://www.roblox.com/asset/?id=anim"
local rockThrowAnimTrack = humanoid:LoadAnimation(rockThrowAnim)
hitbox.onTouch = function(enemyHum)
if enemyHum ~= humanoid then
local enemy = enemyHum.Parent
local enemyHumRp = enemy.HumanoidRootPart
local BlockBreak = true
local damage = 10
local stunDuration = nil
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(100000,100000,100000)
bv.Velocity = Vector3.new(0,40,0)
bv.Parent = enemyHumRp
game.Debris:AddItem(bv,0.2)
rockBezier(humanoidRootPart)
hitService.hit(enemyHum,nil,nil,nil,character,nil,nil,nil,nil,nil)
rockThrowAnimTrack:Play()
end
end
animationTrack.KeyframeReached:Connect(function(kf)
if kf == "flip" then
rockModule.RockFlip(humanoidRootPart)
hitbox:Start()
task.wait(0.1)
hitbox:Destroy()
end
end)
end)
here is a video showing what is happening: