-
What do you want to achieve?
I wanted to make the projectiles when it was close enough to the ground to stick to it and cause detection, but because the parts are fast, sometimes the Cast doesn’t detect it and it goes through the ground, and when it doesn’t go through because the distance is too great, it ends up teleported and looking kind of weird, so I tried using DeltaTime and discovered that I don’t really know how to use it.
- Code and Video
Event = RSE.Stepped:Connect(function(DeltaTime)
if (Projectile.Position - RootPart.Position).Magnitude > SkillTable.Distance then
if BV then
BV:Destroy()
Direction = Vector3.new(0, -1, 0)
end
end
local Cast : RaycastResult = workspace:Raycast(Projectile.Position, Direction * 999, Params)
if Cast and Cast.Distance < (1 * DeltaTime) then
if BV then BV:Destroy() end
Projectile.Anchored = true
Projectile.Position = Cast.Position
local Detection = HitModule:HitBox(Character, {
["Type"] = "Magnitude",
["Range"] = SkillTable.Range,
["CFrame"] = CFrame.new(Cast.Position),
})
Remotes.Effects:FireAllClients("GroundSmash", {
["Position"] = Cast.Position,
["Distance"] = 10,
["MaxRocks"] = 15,
["Size"] = Vector3.new(2, 2, 2),
["Cracked"] = true,
["Duration"] = 15
})
if Detection then
local Hitted = HitModule:HitApply(Character, Detection, SkillTable.HitTable)
if Hitted then
for TCharacter, Table in pairs(Hitted) do
local TRootPart = TCharacter:FindFirstChild("HumanoidRootPart")
if Table["Fling"] and TRootPart then
Table["Fling"].Part = TRootPart
Table["Fling"].Direction = {Vector3.new(math.random(0, 25) / 100, 1, math.random(0, 25) / 100)}
MainModule:Velocity(Table["Fling"])
end
end
end
end
task.delay(15, function()
local Tween = TSE:Create(Projectile, TweenInfo.new(1, Enum.EasingStyle.Linear), {["Size"] = Vector3.new(0.001, 0.001, 0.001)})
Tween:Play()
Tween.Completed:Wait()
Cache:ReturnPart(Projectile)
end)
if Event then Event:Disconnect() end
end
--
RSE.Stepped:Wait()
end)