How do I make a character model rotate in a viewport frame

I want it so that the character model rotates in a viewport frame. I can’t seem to make the model appear in the viewport frame. I had a script for rotating objects and tried messing with that script and I can’t seem to figure it out I also looked it up I found no help there. The character model is a dummy and a player model.

Here is the script i tried with it

cam.CameraType = "Scriptable"
script.Parent.CurrentCamera = cam

local rotValue = 0

game:GetService("RunService").RenderStepped:Connect(function()
	local cframe = script.Parent.Bob.HumanoidRootPart.CFrame * CFrame.Angles(0, math.rad(rotValue), math.rad(180)) * CFrame.new(0, -0.2, 2)
	cam.CFrame = CFrame.new(cframe.p, script.Parent.Bob.HumanoidRootPart.CFrame)
	
	rotValue = rotValue + 1
end)

Capture

1 Like

i think you need to remove cameraType because it’s don’t need.

Doesn’t work here is one of the errors.

1 Like

umm try go to this topic

[How to make camera rotate around model in ViewPort Frame while mantaining set distance and angles - Help and Feedback / Scripting Support - DevForum | Roblox](How to make camera rotate around model in ViewPort Frame while mantaining set distance and angles)

it works perfectly fine but it doesn’t seem to work with dummy or player models. I need to grab a part of the dummy and then it will work am not sure.
here the normal version of the code (it works)


cam.CameraType = "Scriptable"

script.Parent.CurrentCamera = cam

local rotValue = 0

game:GetService("RunService").RenderStepped:Connect(function()

local cframe = script.Parent.Model.EasternElfEars.Handle.CFrame * CFrame.Angles(0, math.rad(rotValue), math.rad(180)) * CFrame.new(0, -0.2, 2)

cam.CFrame = CFrame.new(cframe.p, script.Parent.Model.EasternElfEars.Handle.Position)

rotValue = rotValue + 1

end)
1 Like

To fix the error you provided here, try this;

cam.CameraType = "Scriptable"
script.Parent.CurrentCamera = cam

local rotValue = 0

game:GetService("RunService").RenderStepped:Connect(function()
	local cframe = script.Parent.Bob.HumanoidRootPart.CFrame * CFrame.Angles(0, math.rad(rotValue), math.rad(180)) * CFrame.new(0, -0.2, 2)
	cam.CFrame = CFrame.new(cframe.p, script.Parent.Bob.HumanoidRootPart.Position)
	
	rotValue = rotValue + 1
end)

If the normal version of the code works, this should work just as fine as well considering that the ‘lookAt’ component of the CFrame is now a Vector3 which prevents that error from happening. I will say the angles may need to be changed purely depending on the orientation of ‘Bob’ itself. Make sure to mark as correct if this helps you! :grinning_face_with_smiling_eyes: :+1:

1 Like

Thanks, I have a little question if happened to know how to make a UiGridLayout fit on all device screens. You do not have to answer this.

Any CellPadding or CellSize property needs to use Scale sizing instead of Offset to make it fit on all screen devices.

image

Am still confused I messed with it and it still doesn’t work.