Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)


1 comment

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.