New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
1

# I keep getting (nil value) when trying to rotate a part, how do I fix this?

game.Workspace.part.Orientation =

I've tried

game.Workspace.yeet.Orientation = Orientation.new(x,y,z) didnt work and some others.

(I'm starting to script btw)

0
Edited 14 days ago

If you just want to move the part then just utilize Vector-3 If you want to use another datatype which is used to alternate the Orientation. Then we use CFrame.

Lets start by printing the CFrame

local Part = script.Parent
print(Part.CFrame)


Now this may look confusing but it's not. We are printing where the block is, including the orientation.

Now we want to change the CFrame by doing this.

local Part = script.Parent


"Why are we setting the CFrame equals to itself, times the degree, and why do we use math.rad???

Good question.

If we just do like this

local Part = script.Parent


It wont work, because it does not know what to do with the Part.CFrame, so that's a brief background why you set it to itself

Well math.rad converts it into degrees so if we just did

local Part = script.Parent
Part.CFrame = CFrame.Angles(0, 45, 0)


It would think we wanted to move it.

Here is the full script

local Part = script.Parent


Hope you learned something new!

0
Feahren 3677
14 days ago
Edited 14 days ago

Orientation is not an existing datatype. The datatype required must match the datatype you're trying to cast a new to, since Orientation is a three-dimensional vector, we need to cast a Vector3 datatype instead.

local Part = workspace.yeet
Part.Orientation = Vector3.new(0,0,0)

game.Workspace.yeet.Orientation = Vector3.new("Put the values you want to put here")