-- 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]
local Bindable_Function = script.Function
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)
Bindable_Function:Invoke(Dash_Direction)
else
return
end
end)
Custom_Dash_Key.Changed:Connect(function(new_DashKey)
Dash_Key = Enum.KeyCode[new_DashKey]
end)
-- First Script (Server Script) - New 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 * CFrame.new(Vector3.new(0, 0, 2))
Mini_Dash_Circle_Clone.Parent = workspace
local Disappear_Tween = TweenService:Create(Mini_Dash_Circle_Clone, TweenInfo.new(0.5, Enum.EasingStyle.Linear), {Transparency = 1})
Disappear_Tween:Play()
Disappear_Tween.Completed:Wait()
Mini_Dash_Circle_Clone:Destroy()
end)
task.spawn(function()
Dash_Circle_Clone.CFrame = HRP_CFrame * CFrame.new(Vector3.new(0, 0, 4))
Dash_Circle_Clone.Parent = workspace
local Disappear_Tween = TweenService:Create(Dash_Circle_Clone, TweenInfo.new(1, Enum.EasingStyle.Linear), {Transparency = 1})
Disappear_Tween:Play()
Disappear_Tween.Completed:Wait()
Dash_Circle_Clone:Destroy()
end)
end
Dash_Function.OnServerInvoke = function(Dash_Direction)
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 Dash_Strength = 50
local Minimum_Dash_Strength = Dash_Strength * 0.15
local Amount_of_Iterations = Dash_Strength / Rate
local Removal_of_Strength_Per_Iteration = Dash_Strength / Amount_of_Iterations
for i = 0, Dash_Duration, Rate do
if Dash_Direction == "Front" then
BodyVelocity.Velocity = HRP.CFrame.LookVector * Dash_Strength
elseif Dash_Strength == "Back" then
BodyVelocity.Velocity = (HRP.CFrame.LookVector * -1) * Dash_Strength
elseif Dash_Strength == "Right" then
BodyVelocity.Velocity = HRP.CFrame.RightVector * Dash_Strength
elseif Dash_Direction == "Left" then
BodyVelocity.Velocity = (HRP.CFrame.RightVector * -1) * Dash_Strength
end
if Dash_Strength > Minimum_Dash_Strength then
Dash_Strength -= Removal_of_Strength_Per_Iteration
if Dash_Strength < Minimum_Dash_Strength then
Dash_Strength = Minimum_Dash_Strength
end
end
task.wait(Rate)
end
BodyVelocity:Destroy()
task.wait(COOLDOWN)
debounce = false
end
-- Second Script (Local Script) - Old Script
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Sounds = ReplicatedStorage:WaitForChild("Sounds")
local Dash_SFX = Sounds:WaitForChild("Dash")
local Dash_Function = script.Parent
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local Humanoid = character:FindFirstChild("Humanoid")
local HRP = character:FindFirstChild("HumanoidRootPart")
local Dash_Duration = 0.35
local Rate = 0.01
Dash_Function.OnInvoke = function(Dash_Direction)
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.MaxForce = Vector3.new(100000, 0, 100000)
BodyVelocity.Parent = HRP
local Dash_Strength = 50
local Minimum_Dash_Strength = Dash_Strength * 0.15
local Amount_of_Iterations = Dash_Strength / Rate
local Removal_of_Strength_Per_Iteration = Dash_Strength / Amount_of_Iterations
for i = 0, Dash_Duration, Rate do
if Dash_Direction == "Front" then
BodyVelocity.Velocity = HRP.CFrame.LookVector * Dash_Strength
elseif Dash_Strength == "Back" then
BodyVelocity.Velocity = (HRP.CFrame.LookVector * -1) * Dash_Strength
elseif Dash_Strength == "Right" then
BodyVelocity.Velocity = HRP.CFrame.RightVector * Dash_Strength
elseif Dash_Direction == "Left" then
BodyVelocity.Velocity = (HRP.CFrame.RightVector * -1) * Dash_Strength
end
if Dash_Strength > Minimum_Dash_Strength then
Dash_Strength -= Removal_of_Strength_Per_Iteration
if Dash_Strength < Minimum_Dash_Strength then
Dash_Strength = Minimum_Dash_Strength
end
end
task.wait(Rate)
end
BodyVelocity:Destroy()
end
I’m making a dash function for the character and I wanted to make a model when dashing (Old script was the local script or 2nd script) but of course the model wouldn’t appear for everyone else because originally it was a local script so I tried using a server script to replicate the model to every player but it did work but broke the dash function. The server script successfully replicated the model to every player but the player didn’t dash at all? The script looked perfectly fine to me and there were no errors or warns.