Model won't rotate

  1. What am I making? I’m making a placement system, the script is placed in startergui and it’s a localscript.

  2. What do I want to achieve? If the player holds R or Q on their keyboard, the model keeps rotating and if the player stops, then the model stops rotating

  3. What is the issue? The model won’t rotate, no errors in output too

  4. What solutions have you tried so far? No solutions so far

local Player = game:GetService("Players").LocalPlayer
local UIS = game:GetService("UserInputService")
local Storage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")

local Folder = Storage:FindFirstChild("Furniture")
local Model = Folder:FindFirstChild("Table")
local Mouse = Player:GetMouse()
local UI = script.Parent

local NewModel = Model:Clone()
NewModel.PrimaryPart = NewModel.Hitbox

local Loop = false
local Loopq = false

for i,v in pairs(UI.ScreenGui:GetChildren()) do
	if v:IsA("TextButton") then
		UI.ScreenGui.TextButton.MouseButton1Click:Connect(function()
			NewModel.Parent = game.Workspace
			
			RunService.RenderStepped:Connect(function()
				Mouse.TargetFilter = NewModel
				local NewCFrame = CFrame.new(Mouse.Hit.X, Mouse.Hit.Y, Mouse.Hit.Z)
				NewModel:SetPrimaryPartCFrame(NewCFrame)
			end)
			
			UIS.InputBegan:Connect(function(Input)
				if UIS:IsKeyDown(Enum.KeyCode.Q) then
					Loopq = true
					while Loopq do
						wait()
						local y = NewModel.PrimaryPart.Orientation.Y
						y = y - 3
						NewModel:SetPrimaryPartCFrame(CFrame.Angles(0, math.rad(y), 0))
					end
				end
			end)
			
			UIS.InputEnded:Connect(function(Input)
				if UIS:IsKeyDown(Enum.KeyCode.Q) then
					Loopq = false
				end
			end)
			
			UIS.InputBegan:Connect(function(Input)
				if UIS:IsKeyDown(Enum.KeyCode.R) then
					Loop = true
					while Loop do
						wait()
						local y = NewModel.PrimaryPart.Orientation.Y
						y = y + 3
						NewModel:SetPrimaryPartCFrame(CFrame.Angles(0, math.rad(y), 0))
					end
				end
			end)
			
			UIS.InputEnded:Connect(function(Input)
				if UIS:IsKeyDown(Enum.KeyCode.R) then
					Loop = false
				end
			end)
		end)
	end
end

Is the Model Anchored?
Try putting some print() statements in the script to see where it’s getting to.

The model is anchored and print() works though

But there are no print statements. Try putting something like

if UIS:IsKeyDown(Enum.KeyCode.R) then
print(“R pressed”)

and similar inside each function to see what is and isn’t being called.

Sorry if I’m that guy that just posts links, but this helped me a ton when working on my own placement system hopefully I’m not sending something you have already seen.

Check out this video: How to Make A Placement System in Roblox Studio - YouTube

yea I did try that and they’re all being called

dgdfghgh

yup It’s devking, this is the vid that helped me make my own placement system too

I might have spotted something, You have a statement that if the Q key is down set it to true and if its down set it to false,

UIS.InputBegan:Connect(function(Input)
	-- HERE		if UIS:IsKeyDown(Enum.KeyCode.Q) then
				Loopq = true
				while Loopq == true do
					wait()
					local y = NewModel.PrimaryPart.Orientation.Y
					y = y - 3
					NewModel:SetPrimaryPartCFrame(CFrame.Angles(0, math.rad(y), 0))
				end
			end
		end)

		UIS.InputEnded:Connect(function(Input)
	-- HERE		if UIS:IsKeyDown(Enum.KeyCode.Q) then
				Loopq = false
			end
		end)

If I’m correct you are just enabling it to true and false at the same time so you don’t have time to do anything.

Sorry if this is not correct and im way off its been a long day haha

Sorry for late reply, what do I do to fix this?

Try just rotating the object by 45 degrees when pressing q or r then work from there if you want to hold down and rotate use render step to increase by degrees over time

			UIS.InputBegan:Connect(function()
				if UIS:IsKeyDown(Enum.KeyCode.R) then
					RunService.RenderStepped:Connect(function()
						local y = NewModel.PrimaryPart.Orientation.Y
						y = y + 3
						NewModel:SetPrimaryPartCFrame(CFrame.Angles(0, math.rad(y), 0))
					end)
				end
			end)

is it like this?

Try it and find out :wink: coding is a puzzle have fun doing it I’m not at my computer so I can’t check for you