so i am working on a third person shooter game
Devlogs :- #Devlog1Here #Devlog2Here #Devlog3Here #Devlog4Here
in my game i have a custom backpack that shows the items that the player have in a scrolling frame , this is not the problem , the problem is i use viewportframes to make images for the tools and i use math.deg to rotate the camera to make the icon look nice but some times it gives a random value ! i was using math.rad before but changed it to math.deg because of this but it does not fix it
here is a screen shot to make it easier to understand :-
as you can see the last button image is different from the others
here the code that calculate the camera position :-
local Camera = Instance.new("Camera")
Camera.Parent = Clone.ViewportFrame
Clone.ViewportFrame.CurrentCamera = Camera
local ItemClone = Tool.PrimaryPart:Clone()
ItemClone.Parent = Clone.ViewportFrame
ItemClone.Orientation = Vector3.zero
Camera.CFrame = CFrame.new(ItemClone.Position + ItemClone.CFrame.RightVector * 1.5 , ItemClone.Position) * CFrame.Angles(0 , 0 , math.deg(270))
As the issue happened when you were using both rad and deg, and you are only rotating the camera, I can only conclude that the potion bottle thing is at an angle when it is created. Please check that it isn’t.
Does the object that gets rotated ‘randomly’ change at all (as in, does the colour of the potion that is affected change, and does the extent of the rotation change)?
CFrame.Angles takes angles in radians, which ranges from 0 to 2pi. math.deg converts a value, which is assumed to be in radians, to degrees. math.rad does the opposite; it converts degrees to radians. Put math.rad(270) in instead.