Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does mouse.hit.p x orientation vary based on y axis?

Asked by 2 years ago

Found this script that shoots a projectile but its gets more tilted based on how high its fired please help

script.Parent.OnServerEvent:Connect(function(plr,direction,mouseaim)
    local hrp = plr.Character:WaitForChild("HumanoidRootPart")
    local Slash = game.ReplicatedStorage.Yoru.YoruX:Clone()
    Slash.Parent = workspace
    Slash.CanCollide = false
    Slash.Anchored = false
    Slash.CFrame = CFrame.new(hrp.CFrame.p,direction.p) --direction is mouse.hit.p
    Slash.Orientation = Slash.Orientation + Vector3.new(0,-90,0)
    Slash.Touched:Connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= plr.Name then
            if not hit.Parent.Humanoid:FindFirstChild(plr.Name) then
                local Damage = math.random(40)
                hit.Parent.Humanoid:LoadAnimation(script.HitDamage):Play()
                hit.Parent.Humanoid:TakeDamage(Damage)
            end
        end
    end)
    local BV = Instance.new("BodyVelocity",Slash)
    BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
    BV.Velocity = CFrame.new(hrp.Position,mouseaim).LookVector * 125
    wait(1.2)
    for i = 1,10 do
        wait(0.1)
        Slash.Transparency = Slash.Transparency + 0.015
    end
    wait(100)
    Slash:Destroy()
end)

Answer this question