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 make a model rotate 90 degrees to the right?

How would i make a model rotate 90 degrees to the right when i press r. here is what i have already:

PlayerMouse.KeyDown:connect(function(key)
	if key == "r" then
		if Clone.MovedValue.Value == false then
			local model = Clone.Model
			model.PrimaryPart = model.Center1
			local cframe = model.PrimaryPart.CFrame -- Current CFrame
			model:SetPrimaryPartCFrame(cframe * CFrame.new(0, math.rad(90), 0))
		end
	end
end)

So far it moves it up and doesn't rotate.

1 answer

You can multiply by the CFrame.Angles constructor in order to orientate the model.

local cframe = model.PrimaryPart.CFrame

model:SetPrimaryPartCFrame(cframe * CFrame.Angles(0, math.rad(90), 0))

3 comments

0

It works but it keeps on changing the direction it rotates any ways i can fix this?

0

If I understand the issue correctly, you should add a debounce.

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