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

How do you add a rotation feature to a model?

Hello. So, I have it when you select a tool, a model will spawn that lets you freely place it on your claimed land. It works perfectly. But now I need rotation.

How do I add a rotation feature using the R key?

2 comments

0

edited

0

Dude, I answered your question. If you want to know how to make a click function, ask another one.

1 answer

Ok, so you need two things here.

  • how to do something on r press

  • how to rotate a model

model = something:FindFirstChild("Whatever").Anything

for q=1,360 do
	model:SetPrimaryPartCFrame( --you'll need a primary part
		model:GetPrimaryPartCFrame()* --the current cframe
		CFrame.Angles(math.rad(1),0,0) --rotate
		)
end

I'm assuming you already know how to do things when you press a key, but if you don't, tell me in a comment.

As for the r pressing, do that like this.

game:GetService("UserInputService").InputBegan:connect(function(key)
	if key.KeyCode == Enum.KeyCode.R then
		--do some rotate stuff
	end
end)

4 comments

0

The only way I know is using KeyDown. I tried, and couldn't get it to work. Mind editing your answer and adding the "Press R" function to the current code. Thanks!

0

It's not working. This needs to be in a onClicked function because it is when a user selects the tool. When they select the tool, they will be able to press "R", and rotate the item. How would I do this?

1

Nice answer <3

0

Thanks :D

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