-- Local Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local DashFunction = script:WaitForChild("Dash_Function")
local LocalPlayer = game.Players.LocalPlayer
local Custom_Dash_Key = LocalPlayer:WaitForChild("Dash_Key")
local Dash_Key = Enum.KeyCode[Custom_Dash_Key.Value]
UserInputService.InputBegan:Connect(function(input, processed)
if processed == true then return end
if input.KeyCode == Dash_Key then
local Dash_Direction = "Front"
if UserInputService:IsKeyDown(Enum.KeyCode.S) then
Dash_Direction = "Back"
elseif UserInputService:IsKeyDown(Enum.KeyCode.A) then
Dash_Direction = "Left"
elseif UserInputService:IsKeyDown(Enum.KeyCode.D) then
Dash_Direction = "Right"
end
DashFunction:InvokeServer(Dash_Direction)
else
return
end
end)
Custom_Dash_Key.Changed:Connect(function(new_DashKey)
Dash_Key = Enum.KeyCode[new_DashKey]
end)
-- Server Script
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sounds = ReplicatedStorage:WaitForChild("Sounds")
local Dash_SFX = Sounds:WaitForChild("Dash")
local Modules = ReplicatedStorage:WaitForChild("Modules")
local Miscellaneous_Modules = Modules:WaitForChild("Miscellaneous_Modules")
local Miscellaenous = require(Miscellaneous_Modules:WaitForChild("Miscellaneous"))
local Models = ReplicatedStorage:WaitForChild("Models")
local Dash_Circle = Models:WaitForChild("Dash_Circle")
local Mini_Dash_Circle = Models:WaitForChild("Mini_Dash_Circle")
local Dash_Function = script.Parent
local character = Dash_Function.Parent.Parent
local Humanoid = character:FindFirstChild("Humanoid")
local HRP = character:FindFirstChild("HumanoidRootPart")
local debounce = false
local COOLDOWN = 8
local Dash_Duration = 0.35
local Rate = 0.01
local function Clone_Dash_Circles(player_HRP)
local HRP_CFrame = HRP.CFrame
local Dash_Circle_Clone = Dash_Circle:Clone()
local Mini_Dash_Circle_Clone = Mini_Dash_Circle:Clone()
task.spawn(function()
Mini_Dash_Circle_Clone.CFrame = HRP_CFrame + Vector3.new(0, 0, 2)
Mini_Dash_Circle_Clone.Parent = workspace
end)
task.spawn(function()
Dash_Circle_Clone.CFrame = HRP_CFrame + Vector3.new(0, 0, 4)
Dash_Circle_Clone.Parent = workspace
end)
end
Dash_Function.OnServerInvoke = function(DashDirection)
if debounce == true then return end
debounce = true
task.spawn(Miscellaenous.Play_Sound, Dash_SFX, HRP)
task.spawn(Clone_Dash_Circles, HRP)
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.MaxForce = Vector3.new(100000, 0, 100000)
BodyVelocity.Parent = HRP
local DashStrength = 50
local MinimumDashStrength = DashStrength * 0.15
local AmountofIterations = DashStrength / Rate
local RemovalofStrengthPerIteration = DashStrength / AmountofIterations
for i = 0, Dash_Duration, Rate do
if DashDirection == "Front" then
BodyVelocity.Velocity = HRP.CFrame.LookVector * DashStrength
elseif DashDirection == "Back" then
BodyVelocity.Velocity = (HRP.CFrame.LookVector * -1) * DashStrength
elseif DashDirection == "Right" then
BodyVelocity.Velocity = HRP.CFrame.RightVector * DashStrength
elseif DashDirection == "Left" then
BodyVelocity.Velocity = (HRP.CFrame.RightVector * -1) * DashStrength
end
if DashStrength > MinimumDashStrength then
DashStrength -= RemovalofStrengthPerIteration
if DashStrength < MinimumDashStrength then
DashStrength = MinimumDashStrength
end
end
task.wait(Rate)
end
BodyVelocity:Destroy()
task.wait(COOLDOWN)
debounce = false
end
I’m new to modeling and I’m trying to make a dash effect. The large circle will be the most behind the player and the mini dash circle will be a little bit behind the player (both using the player’s HRP’s CFrame) but I can’t get them to center and it’s very off. I don’t know what to do?
