Ok so basically i’m making a sword skill which makes a slash shoot outward as a projectile. As far as shooting it out, it works. But my problem is it only shoots out in one direction instead of in front of the character, i’ve went around on discord asking for help but nobody seems to know the answer so I’ve finally decided to bring this up here hoping someone knows why this is happening.
Here is my code:
Server Sided:
local Active = false
local HitNumber = 0
local slasho = game.ReplicatedStorage.Slash:Clone()
game.ReplicatedStorage:WaitForChild(“SwingEvent2”).OnServerEvent:Connect(function(player)
Active = true
local swinganim = Instance.new(“Animation”)
swinganim.AnimationId = game:GetService(“ReplicatedStorage”):WaitForChild(“SwordConfiguration”).Swing.Value
local swinganimtrack = player.Character.Humanoid:LoadAnimation(swinganim)
swinganimtrack:Play()
player.Character.Sword.Sword.Swing:Play()
slasho.Parent = game.Workspace
slasho.CFrame = player.Character.Torso.CFrameCFrame.new(0,0,-5)
–slasho.CFrame = slasho.CFrame * CFrame.fromEulerAnglesXYZ(1.5,0,0)
local BV = Instance.new(“BodyVelocity”,slasho)
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = player.Character.HumanoidRootPart.CFrame.lookVector150
delay(.360,function()
local attachment0 = Instance.new(“Attachment”,player.Character.Sword.Sword)
attachment0.Position = Vector3.new(0.087, -0, -0.501)
local attachment1 = Instance.new(“Attachment”,player.Character.Sword.Sword)
attachment1.Position = Vector3.new(0.078, -0, 2.272)
local trail = player.Character.Sword.Sword.Trail
trail.Attachment0 = attachment0
trail.Attachment1 = attachment1
delay(.490,function()
attachment0:Destroy()
attachment1:Destroy()
swinganim:Destroy()
swinganimtrack:Stop()
end)
end)player.Character.Sword.Sword.Touched:Connect(function(toucher)
if toucher.Parent:FindFirstChild(“Humanoid”) ~= nil then
if game:GetService(“ReplicatedStorage”).HitVals:FindFirstChild(“HitVal”…toucher.Parent.Name) == nil then
local hitted = toucher.Parent
print(toucher.Parent.Name)
toucher.Parent.Humanoid:TakeDamage(game.ReplicatedStorage:WaitForChild(“SwordConfiguration”).Damage.Value)
local hitter = Instance.new(“Folder”,game:GetService(“ReplicatedStorage”).HitVals)
hitter.Name = “HitVal”…toucher.Parent.Name
end
end
end)
Active = false
for i,v in pairs(game:GetService(“ReplicatedStorage”).HitVals:GetChildren()) do
v:Destroy()
end
end)
I am not looking for someone to give me the code, I am simply looking to learn why it is doing this and how I can fix it or if there are better methods to doing this.