Rotating a Client-Sided Model

Hi, I would like to rotate a Model(That exists only on the client) using a ModuleScript.

I tried to rotate it the normal way, but it just doesn’t rotate(no errors on the console):

UIS.InputBegan:Connect(function(inputObject)
	if inputObject.UserInputType == Enum.UserInputType.Keyboard then
		local value = inputObject.KeyCode.Value
		if value == 114 then
			if script.Parent.Configuration.UnitEditor.Value == true then
				if Unit then
					--print("x")
					Unit:SetPrimaryPartCFrame(Unit.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(90), 0))
				end
			end
		end
	end
end)

I tried searching for problems like this one and I couldn’t find(only found a client-sided script to server-sided model solution), if this is a duplicated topic please reply and I’ll close this one.

1 Like

Did you try debugging? Does it print “x” if you uncomment the print line?

1 Like

is it required by the local script?

Yes, it does print the “x” when uncommented.

The piece of code is inside the ModuleScript and it is being required by a LocalScript.
I know it reaches the Unit:SetPrimaryPartCFrame(Unit.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(90), 0)) because it prints the “x”.

Try using Unit:GetPrimaryPartCFrame() instead.

It isn’t working, the rotation never changes.

UIS.InputBegan:Connect(function(inputObject)
	if inputObject.UserInputType == Enum.UserInputType.Keyboard then
		local value = inputObject.KeyCode.Value
		if value == 114 then
			if script.Parent.Configuration.UnitEditor.Value == true then
				if Unit then
					Unit:SetPrimaryPartCFrame(Unit:GetPrimaryPartCFrame() * CFrame.Angles(0, math.rad(90), 0))
					print(Unit.PrimaryPart.CFrame)
				end
			end
		end
	end
end)

I cant understand why, but it works this way:

Unit.PrimaryPart.CFrame *= CFrame.Angles(0, math.rad(90), 0)

Thanks for all the help.