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

How can i make my player face a certain way when i run this code?

Asked by 5 years ago

I'm trying to make a dodge which suspends you in the air while also moving you in one direction, i have achieved that by using tweenservice and CFrame, the only problem is whenever I run this code it turns my player in a fixed rotation, right now my player moves right but my character is looking forward. this is my code

game.ReplicatedStorage.Dodge.OnServerEvent:Connect(function(player)
    local tweenService = game:GetService("TweenService")
    local part = player.Character.HumanoidRootPart

    game.Workspace.DodgeCircle.Transparency = 0
    player.Character.HumanoidRootPart.Anchored = true
    local goal = {}
    goal.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position + Vector3.new(25,0,0))
    local tweenInfo = TweenInfo.new(.2)
    local tween = tweenService:Create(part, tweenInfo, goal)
    tween:Play()

    wait(.2)
    game.Workspace.DodgeCircle.Transparency = 1
    player.Character.HumanoidRootPart.Anchored = false
end)


1 answer

Log in to vote
0
Answered by 5 years ago

I Fixed this by adding CFrame.Angles into my script the final script looks something like this

game.ReplicatedStorage.Dodge.OnServerEvent:Connect(function(player)
    local tweenService = game:GetService("TweenService")
    local part = player.Character.HumanoidRootPart

    game.Workspace.DodgeCircle.Transparency = 0
    player.Character.HumanoidRootPart.Anchored = true
    local goal = {}
    goal.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position + Vector3.new(25,0,0)) * CFrame.Angles(0, -1.5, 0)
    local tweenInfo = TweenInfo.new(.2)
    local tween = tweenService:Create(part, tweenInfo, goal)
    tween:Play()

    wait(.2)
    game.Workspace.DodgeCircle.Transparency = 1
    player.Character.HumanoidRootPart.Anchored = false
end)


0
When using CFrame.Angles, make sure that the Angle you put in is in radians. You can use math.rad(90) to convert a number in degrees into radians! InfinityEngine 223 — 5y
Ad

Answer this question