Why can't my Frame be changed by division?

I am making a gun script and this local script I am showing below fires the remote event to create a recast. When I fire the gun I also change the camera frame by multiplying it to make recoil. The recoil is rather smooth but I want the camera to naturally come down after firing. I decided to divide by the same number after each camera movement but for some reason it says that it attempted division in red and doesn’t work. I am new to scripting so if I am making a simple mistake I won’t be surprised.

local RunService:RunService = game:GetService("RunService")
local Players:Players = game:GetService("Players")
local Player = Players.LocalPlayer
local char  = script.Parent.Parent
local Mouse = Player:GetMouse()


local Tool:Tool = script.Parent
local RemoteEvent:RemoteEvent = script.Parent.RemoteEvent
local Holdable,Holding = true,false 

function Send() 
	RemoteEvent:FireServer({Position = Mouse.Hit.Position})
end
	

	Tool.Activated:Connect(function()
		Holding = true
		if Holdable then
			local Run
			Run = RunService.Heartbeat:Connect(function()
				if not Holding then
					Run:Disconnect()
				end
			Send()
			workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(math.rad(1.1),0,0)
			wait(0.01)
			workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame / CFrame.Angles(math.rad(1.1),0,0)
			end)
		else
		Send()

		end
	end)

	Tool.Deactivated:Connect(function()
		Holding = false
	end)

	Tool.Unequipped:Connect(function()
		Holding = false
	end)
1 Like

I’m not sure why at the engine level, but the way I see it is that multiplication is equivalent to adding CFrames and that’s the only operation that there is to it.

If you’d want to actually divide CFrames, (since I have no idea what you were trying to do with your code :sob: ) you’d need to turn them into Vector3s and then back into CFrames once divided.

You can’t divide CFrames; you can do this instead:

workspace.CurrentCamera.CFrame *= CFrame.Angles(-math.rad(1.1),0,0)
2 Likes

I completely forgot that *= was a thing, thanks for the reminder LOL

I am trying to make gun recoil by moving the camera up and down in angles

oh ok didn’t know that thank you I will try it

Thank you it worked just like I need it have a good day :slight_smile:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.