How to set rotation of a model

I want to set the orientation of a model to x of 90 and 0 depending and be able to move it around wherever and still works using TweenService


  1. I tried doing CFrame but it kept on going back to the original position

heres the model im using with a script as a base model

inside the script:

local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")

local Up = TweenService:Create(script.Parent, TweenInfo.new(1), {Orientation = 90})


local Down = TweenService:Create(script.Parent, TweenInfo.new(1), {Orientation = 0})


local toggle = true

local Key = Enum.KeyCode.V


UserInputService.InputBegan:Connect(function(input, _gameProcessed)
	if input.KeyCode == Key then
		if toggle then
			Down:Play()
			toggle = false
		else
			Up:Play()
			toggle = true
		end
	end
end)

Sorry, I don’t quite understand this statement well. Can you explain more?

look at the screen shots it basically want i want them to do top screenshot is orientation X of 0 and second is 90

So X has to be both 0 and 90?
Not possible
Do you want them to Tween? Change?

i want the tween the orientation of X like if i do Down:play() it will set the orientation x to 0 and if i do up:play() it will set the orientation x to 90 not at the same time.

You would set up a Tween like:

local part = part.here
local info = TweenInfo.new(1) --amount of seconds and easing styles
local targetDown = {part.Orientation = Vector3.new(0,0,0)}
local targetUp = {part.Orientation =Vector3.new(90,0,0)}
local tweenDown = game:GetService(“TweenService”):Create(part, info, targetDown)
local tweenUp = game:GetService(“TweenService”):Create(part, info, targetUp)

And then you simply call them in a Function

(Also part is the PrimaryPart)

based on your code the tween is going to move the model not rotate

@Dede_4242 your code is wrong. You need to provide a dictionary containing all the properties needed to be tween in the last argument for the Create function.

1 Like

You need to use weld and PrimaryPart for the model and you can’t use UserInputService in server scripts, you have to do it via local script and RemoteEvent

If I’m not wrong it’ll not, as Vector3 is a vector, to move you usually need CFrame
Also I just noticed I messed up everything so lemme edit the script

Sorry, I wrote it on phone from my mind so there surely is an error

Try it now, it should work as I edited the code

Please explain further
i welded all the parts to the primarypart
i made a local script wich works

local UserInputService = game:GetService("UserInputService")

local Key = Enum.KeyCode.V
local toggle = false

UserInputService.InputBegan:Connect(function(input, _gameProcessed)
	if input.KeyCode == Key then
		if toggle then
			game.Workspace.Goggles.Toggle:FireServer('Down')
			toggle = false
		else
			game.Workspace.Goggles.Toggle:FireServer('Up')
			toggle = true
		end
	end
end)

but the tweening service still doesnt work
server script:

local TweenService = game:GetService("TweenService")
local part = script.Parent.PrimaryPart

local Up = TweenService:Create(part, TweenInfo.new(1), {Orientation = Vector3.new(90,part.Orientation.Y,part.Orientation.Z)})


local Down = TweenService:Create(part, TweenInfo.new(1), {Orientation = Vector3.new(0,part.Orientation.Y,part.Orientation.Z)})

script.Parent.Toggle.OnServerEvent:Connect(function(plr, toggle)
	if toggle == 'Up' then
		Up:Play()
	else
		Down:Play()
	end
end)

Try this, if it works, but in the wrong direction - just adjust for yourself

local Up = TweenService:Create(part, TweenInfo.new(1), {CFrame = part.CFrame*CFrame.Angles(math.rad(90), 0, 0)})
local Down = TweenService:Create(part, TweenInfo.new(1), {CFrame = part.CFrame*CFrame.Angles(0, 0, 0)})

the tweening service works but its only rotating the primary part and nothing else and when i move it, it teleports back to its old position.

check if you welded the parts correctly

is weld in the constraints tab

Can you send the model with the script you are currently using?

here oh and i forgot make a local script and put is in starterplayer script:

local UserInputService = game:GetService("UserInputService")

local Key = Enum.KeyCode.V
local toggle = false

UserInputService.InputBegan:Connect(function(input, _gameProcessed)
	if input.KeyCode == Key then
		if toggle then
			game.Workspace.Goggles.Toggle:FireServer('Down')
			toggle = false
		else
			game.Workspace.Goggles.Toggle:FireServer('Up')
			toggle = true
		end
	end
end)

With the welding itself, I want to see if and how you did it