I’m making a dash ability for a game and wanted to add an effect to dashing where frames lag behind you. The issue is that it anchors the player.
Script
--[[SERVICES]]--
local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")
--[[FUNCTIONALITY]]--
--//Getting the player
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local DashAttachment = Instance.new("Attachment",Character.PrimaryPart)
--//Dashing
local DashCD = false
local function DashUser(actionName, inputState)
if actionName == "Dash" and inputState == Enum.UserInputState.Begin then
if DashCD then return end
DashCD = true
--//Dash
local LinearVelocity = Instance.new("LinearVelocity",Character.PrimaryPart)
LinearVelocity.MaxForce = math.huge
LinearVelocity.VectorVelocity = Character.PrimaryPart.CFrame.LookVector * 100
LinearVelocity.Attachment0 = DashAttachment
--//Frames
local FancyFrames = coroutine.create(function()
while task.wait(0) do
for _, Bodypart in pairs(Character:GetChildren()) do
if Bodypart:IsA("BasePart") and Bodypart.Name ~= "HumanoidRootPart" then
local FramePart = Bodypart:Clone()
FramePart.Parent = game.Workspace.Debris
FramePart.CFrame = Bodypart.CFrame + Bodypart.CFrame.LookVector*-3
FramePart.CanCollide = false
FramePart.Anchored = true
game:GetService("Debris"):AddItem(FramePart,0.02)
end
end
end
end)
coroutine.resume(FancyFrames)
game:GetService("Debris"):AddItem(LinearVelocity,1)
task.wait(1)
coroutine.close(FancyFrames)
DashCD = false
end
end
ContextActionService:BindAction("Dash",DashUser,false,Enum.KeyCode.LeftShift)
Removing the welds and motor6d works, but the frames aren’t aligning correctly
--[[SERVICES]]--
local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")
--[[FUNCTIONALITY]]--
--//Getting the player
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local DashAttachment = Instance.new("Attachment",Character.PrimaryPart)
--//Dashing
local DashCD = false
local function DashUser(actionName, inputState)
if actionName == "Dash" and inputState == Enum.UserInputState.Begin then
if DashCD then return end
DashCD = true
--//Dash
local LinearVelocity = Instance.new("LinearVelocity",Character.PrimaryPart)
LinearVelocity.MaxForce = math.huge
LinearVelocity.VectorVelocity = Character.PrimaryPart.CFrame.LookVector * 100
LinearVelocity.Attachment0 = DashAttachment
--//Frames
local FancyFrames = coroutine.create(function()
while task.wait(0) do
for _, Bodypart in pairs(Character:GetChildren()) do
if Bodypart:IsA("BasePart") and Bodypart.Name ~= "HumanoidRootPart" then
local FramePart = Bodypart:Clone()
FramePart.Parent = game.Workspace.Debris
FramePart.CFrame = Bodypart.CFrame + Bodypart.CFrame.LookVector*-3
FramePart.CanCollide = false
FramePart.Anchored = true
--//Removing led and Motor6D's
if FramePart.Name == "Torso" then
for _, Weld in pairs(FramePart:GetChildren()) do
if Weld:IsA("Weld") or Weld:IsA("Motor6D") then
Weld:Destroy()
end
end
end
game:GetService("Debris"):AddItem(FramePart,0.02)
end
end
end
end)
coroutine.resume(FancyFrames)
game:GetService("Debris"):AddItem(LinearVelocity,0.05)
task.wait(1)
coroutine.close(FancyFrames)
DashCD = false
end
end
ContextActionService:BindAction("Dash",DashUser,false,Enum.KeyCode.LeftShift)
Alright. Well, I’m doing the “Clone character, anchor body parts” technique, but it won’t let me parent it to the workspace.
--[[SERVICES]]--
local Players = game:GetService("Players")
local ContextActionService = game:GetService("ContextActionService")
--[[FUNCTIONALITY]]--
--//Getting the player
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local DashAttachment = Instance.new("Attachment",Character.PrimaryPart)
--//Dashing
local DashCD = false
local function DashUser(actionName, inputState)
if actionName == "Dash" and inputState == Enum.UserInputState.Begin then
if DashCD then return end
DashCD = true
--//Dash
local LinearVelocity = Instance.new("LinearVelocity",Character.PrimaryPart)
LinearVelocity.MaxForce = math.huge
LinearVelocity.VectorVelocity = Character.PrimaryPart.CFrame.LookVector * 100
LinearVelocity.Attachment0 = DashAttachment
--//Frames
local FancyFrames = coroutine.create(function()
while task.wait(0.02) do
local FrameChar = Character:Clone()
FrameChar.Parent = game.Workspace.Debris
FrameChar.Head.face:Destroy()
for _, Bodypart in pairs(FrameChar:GetChildren()) do
if Bodypart:IsA("BasePart") then
Bodypart.Anchored = true
Bodypart.CanCollide = false
Bodypart.Transparency = 0.5
Bodypart.BrickColor = BrickColor.new("White")
game:GetService("Debris"):AddItem(Bodypart,0.02)
end
end
end
end)
coroutine.resume(FancyFrames)
game:GetService("Debris"):AddItem(LinearVelocity,0.05)
task.wait(1)
coroutine.close(FancyFrames)
DashCD = false
end
end
ContextActionService:BindAction("Dash",DashUser,false,Enum.KeyCode.LeftShift)