I'm not talking about shooting in the orientation of your humanoidrootpart. I'm talking about where your mouse is clicking. If I am looking in another direction and shoot a skill behind me, the direction would be right, but the orientation would look like my orientation and not the mouse. I want the orientation to look correct, so my skill doesn't like its moonwalking. I think the way we need to do this is to find the orientation of an axis just from the coordinate of the corresponding axis, but I don't know how to do that.
Script
local slash = game.ServerStorage:WaitForChild("Slash")
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.Slash.OnServerEvent:Connect(function(player, mousePos)
local character = player.Character
local newSlash = slash:Clone()
local animation = character.Humanoid:LoadAnimation(script.Parent.SlashAnim)
animation:Play()
newSlash.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
print(mousePos)
newSlash.CFrame = newSlash.CFrame * CFrame.Angles(-55,0,0)
newSlash.Parent = workspace
local velocity = Instance.new("BodyVelocity", newSlash)
velocity.Velocity = CFrame.new(newSlash.Position, mousePos).LookVector * 100
velocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
local touchConn
touchConn = newSlash.Touched:Connect(function(hit)
if hit == nil then return end
if hit.Parent.Name == player.Name then return end
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(40)
if touchConn ~= nil then touchConn:Disconnect() end
newSlash:Destroy()
end
end)
wait(2)
if touchConn ~= nil then touchConn:Disconnect() end
newSlash:Destroy()
end)
end)
