CFrame seems to fly me around the map

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I am trying to make a flash with two different colored bricks that rotate randomly when the gun is shot

  2. What is the issue? Include screenshots / videos if possible!
    When altering the CFrame of the two parts that are supposed to rotate, the gun seems to make me randomly rotate with the parts, instead of the two parts rotating on their own.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve checked to see if the parts were cancollided, I redid weld constraints, and I’ve looked at other gun tutorials including EgoMoose’s tutorial, but none of them seem to get to the point I am needing help with
    I will attach a video of what is happening when I shoot.robloxapp-20200618-0724283.wmv (1.2 MB)

Here is the code I am using to rotate the cframe of the two parts:

local function fire()
	--//Checks
	if canShoot:InvokeServer() then
		--//Initialize
		if recoilTrack then
			recoilTrack:Play()
		end
		--flashGui.Enabled = true
		local rand = math.random(0,360)
		red.Transparency = 0.3
		orange.Transparency = 0.3
		red.CFrame= CFrame.Angles(math.rad(rand),math.rad(rand),math.rad(rand))
		orange.CFrame =CFrame.Angles(math.rad(rand),math.rad(rand),math.rad(rand))

What are the values red, orange? If they are welded to the character (even to the gun), your character WILL move, try making sure nothing is welded to this part.

Hopefully I solved your problem, if I have make sure to let me know.

Ahh, thank you. I am very new to making guns. They are my least favorite things to make. I had these parts welded to the “Hole” of the gun. So what’s the best way create these parts without welding them? Won’t they just fall through the world? Do I need to create a new instance each time I shoot?

Hey, Same thing in here, I HATE making them.

I would recommend you to Instance.new("Part") them, apply the rotation and position, parent them to workspace and maybe even add some cool lighting effects.

Hopefully I solved your problem, if I have make sure to let me know.

Instead of a weld, use a Motor6D which will allow the flash to rotate whilst keeping it all together.

Hey, It worked thank you for letting me know about that with a weld!

Thank you for this advice too, I would try it if I had already not figured it out a different way.