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

How would I order line 20 correctly? (ANSWERED)

On line 20, I'm having problems trying to figure out how to change the character's rotation to face in the direction that I want. I've tried Vector3 and CFrame in so many different orders and read the wiki but it's too complicating!

The output says; LocalScript:20: bad argument #1 to 'new' (Vector3 expected, got CFrame)

Here is the script;

local frame = script.Parent:WaitForChild("Frame")
local button = script.Parent:WaitForChild("TextButton")
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local uif = script.Parent:WaitForChild("UserInterfaceFolder")

uif.Name = player.Name.."InterfaceFolder"
cloned = false

button.MouseButton1Down:connect(function()
	if cloned == false then 
		uif:Clone().Parent = game.Workspace
		cloned = true
	end
	frame.Visible = true
	local playerloc = game.Workspace[player.Name..'InterfaceFolder']
	camera.CameraSubject = playerloc.CameraPart
	player.Character.Torso.CFrame = CFrame.new(Vector3.new(-214.05, 0.7, -223.95))
	wait(1)
	player.Character.Torso.CFrame =  CFrame.new(CFrame.fromEulerAnglesXYZ(0,20,0))
	player.Character.Torso.Anchored = true
end)

2 comments

0

Accept my answer if it brought you to a solution, its just a button click ;)

0

https://gyazo.com/19cbcb1342b760d97477f8435ed4a6d2 See that big ACCEPT ANSWER Button? Click that >:I

1 answer

Angles use radians instead of degrees. to change this we use math.rad(Int Degree). In code this would be

local DesiredAngle = 20
player.Character.Torso.CFrame =  CFrame.new(player.Character.Torso.Position) * CFrame.Angles(0,math.rad(DesiredAngle),0)

Edit: fromEulerAnglesXYZ changed to Angles as fromEulerAnglesXYZ is deprecated.

4 comments

0

Ah. Thanks! :)

0

Note, it doesn't have to be an int, but floats are unaccurate. Thats why i'd always use ints. Please accept the answer if it brought you to a solution, it'll grant us both reputation points :D

0

And if you dont you get reported :< so please accept his answer or after a few days you will get Reported!!

0

Stop, no I won't! I can't even up vote it because I don't have reputation points!

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