-
What do you want to achieve? Keep it simple and clear!
I want a part to rotate when you press the keybind R. For some reason all of the tutorials i have watched don’t work for my part. My part is a union and its a viewmodel for a placement system. -
What is the issue? Include screenshots / videos if possible!
No youtube tutorials helped me. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried YT and Devforum.
Isn’t it just pressing ctrl and R?
I made a localscript that will rotate the union by 45 on the y axis. All you have to do is press R
local userInputService = game:GetService("UserInputService")--the service that handles input
local union = workspace:WaitForChild("Union")--the union
userInputService.InputBegan:Connect(function(input, gameProccesedEvent)
if not gameProccesedEvent then--make sure the player didn't press R while chatting
if input.KeyCode == Enum.KeyCode.R then--if the player presses R
union.Orientation += Vector3.new(0, 45, 0)--rotate 45 on the y axis
end
end
end)
Next time please put 3 backticks (```) before and after your code so it formats properly in your post.
I checked the create.roblox.com page because I’m pretty sure you don’t rotate CFrames by Orientation. Have a look at the ‘Rotating a CFrame’ section here:
CFrames | Documentation - Roblox Creator Hub
Yes, but how do i rotate it???
Thank you for the tip, and apologies for misreading.
Thanks for responding but thats the code i always use but it never works, but ill try it when i get back on my pc and let you know if it works.
This should work now as I made it compatible with CFrame Angles
local userInputService = game:GetService("UserInputService")--the service that handles input
local union = workspace:WaitForChild("Union")--the union
userInputService.InputBegan:Connect(function(input, gameProccesedEvent)
if not gameProccesedEvent then--make sure the player didn't press R while chatting
if input.KeyCode == Enum.KeyCode.R then--if the player presses R
union.CFrame *= CFrame.Angles(0, math.rad(45), 0)--rotate 45 on the y axis (by using CFrame Angles)
end
end
end)
hey, it doesnt work, but i think its because my part is anchored. is there one that works with anchored parts?
maybe this should work?
local userInputService = game:GetService("UserInputService")--the service that handles input
local union = workspace:WaitForChild("Union")--the union's name
userInputService.InputBegan:Connect(function(input, gameProccesedEvent)
if gameProccesedEvent then return end--make sure the player didn't press R while chatting
if input.KeyCode == Enum.KeyCode.R then--if the player presses R
union.CFrame *= CFrame.Angles(0, math.rad(45), 0)--rotate 45 on the y axis (by using CFrame Angles)
end
end
end)
i rewrote some parts
its ok, i figured out another way to do it, thanks for the help tho
You can make the union unanchored rotate it then set it back to anchored
local userInputService = game:GetService("UserInputService")--the service that handles input
local union = workspace:WaitForChild("Union")--the union
userInputService.InputBegan:Connect(function(input, gameProccesedEvent)
if not gameProccesedEvent then--make sure the player didn't press R while chatting
if input.KeyCode == Enum.KeyCode.R then--if the player presses R
union.Anchored = false
union.CFrame *= CFrame.Angles(0, math.rad(45), 0)--rotate 45 on the y axis (by using CFrame Angles)
union.Anchored = true
end
end
end)
Edit: never mind you seem to have solved the issue
Please post how you solved it so everyone reading this post can learn from it, and mark that post as the Solution.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.