(Bad English Warning)
From Youtube tutorial I am trying to make dash system using RayCast
But it only worked with front dash so i decided to upgrade script
The poblem is that left and right dashes do not work but front and back dashes work great
local RS=game:GetService("ReplicatedStorage")
local DS=game:GetService("Debris")
local event=RS.Remotes:WaitForChild("DashEvent")
local DashSound=RS.Sounds:WaitForChild("Dash")
local PS=game:GetService("PhysicsService")
local listOfDebounce={}
for _,player in pairs(game:GetService("Players"):GetChildren()) do
listOfDebounce[player]=false
end
local ignoreList = {}
for _,v in pairs(workspace:GetDescendants())do
if v:IsA("BasePart") or v:IsA("WedgePart") or v:IsA("UnionOperation") then
ignoreList[#ignoreList+1]=v
end
end
function NoCollide(model,Group)
for k,v in pairs (model:GetChildren()) do
if v:IsA"BasePart" then
PS:SetPartCollisionGroup(v,Group)
end
end
end
local function GetDirection(part,front,left,back,right)
if front then
return part.CFrame.LookVector*130+Vector3.new(0,5,0)
elseif left then
return part.CFrame.RightVector*-130+Vector3.new(0,5,0)
elseif back then
return part.CFrame.LookVector*-130+Vector3.new(0,5,0)
elseif right then
return part.CFrame.RightVector*130+Vector3.new(0,5,0)
else
return part.CFrame.LookVector*130+Vector3.new(0,5,0)
end
end
local function tunrOnOff(Table,switch)
for _,particle in pairs(Table) do
particle.Enabled=switch
end
end
local function treeVisibility(character,transparency)
local tool=character:FindFirstChildWhichIsA("Tool")
if tool then
tool.Blade.Trail.Enabled=not tool.Blade.Trail.Enabled
end
for i,v in pairs(character:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("Decal") then
if v.Name=="HumanoidRootPart" or v.Name=="ShadowsDashes" then
continue
end
v.Transparency=transparency
end
end
end
event.OnServerEvent:Connect(function(player,W,A,S,D,shiftLock)
local character=player.Character
local humanoid=character:FindFirstChild("Humanoid")
local humanoidRootPart=character:FindFirstChild("HumanoidRootPart")
local afterImageParticles=character:FindFirstChild("ShadowsDashes"):GetChildren()
local attaking=character:GetAttribute("Attaking")
local stunned=character:GetAttribute("Stunned")
if attaking or stunned or listOfDebounce[player] then
return
end
character:SetAttribute("Stunned",true)
listOfDebounce[player]=true
treeVisibility(character,1)
tunrOnOff(afterImageParticles,true)
NoCollide(character,"Dashing")
local clone=DashSound:Clone()
clone.Parent=humanoidRootPart
clone:Play()
game:GetService("Debris"):AddItem(clone,clone.TimeLength)
local ray=Ray.new(humanoidRootPart.Position,GetDirection(humanoidRootPart,W,A,S,D))
local rayPosition,hitPostition = workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)
print(ray)
local bodyPosition=Instance.new("BodyPosition")
bodyPosition.Name="DashForce"
bodyPosition.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bodyPosition.D=500
bodyPosition.P=400
bodyPosition.Position=hitPostition
local bodyGyro=Instance.new("BodyGyro")
bodyGyro.Name="DashOrientation"
bodyGyro.MaxTorque=Vector3.new(math.huge,math.huge,math.huge)
bodyGyro.D=500
bodyGyro.P=300
bodyGyro.CFrame=humanoidRootPart.CFrame
bodyGyro.Parent=humanoidRootPart
bodyPosition.Parent=humanoidRootPart
task.wait(0.3)
bodyGyro:Destroy()
bodyPosition:Destroy()
treeVisibility(character,0)
tunrOnOff(afterImageParticles,false)
NoCollide(character,"p")
character:SetAttribute("Stunned",false)
task.wait(3)
listOfDebounce[player]=false
end)
The main issue is in GetDirection function I don’t understand well
CFrame.RightVector
Please give me some advice