Anchored part moves down

im making a fps game, i have this part called “bullethole” that follows the tip of the gun, but it does this???

the bright red part is the bullethole, it moves down even though it’s suppose to follow the tip of the gun. and the part is anchored it just moves down for no reason???

here is the script if you need it.

local mouse = game.Players.LocalPlayer:GetMouse()

local remote = script.gunanimations

local fire = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator"):LoadAnimation(script.gunfire)


idle:Play()

local reloading = false

local torso:Part = game.Players.LocalPlayer.Character:FindFirstChild("viewmodel").Torso

local db = false

while task.wait() do
	script.Parent.PistolGrip.important.bullethole.CFrame = torso.CFrame * CFrame.new(1.5, 1.04, -2.55) * CFrame.Angles(90, 0, 0) --debugging
end

mouse.Button1Down:Connect(function()
	if reloading == false then
		if db == false then
			db = true
			if script.Ammo.Value > 0 then
				script.Parent.PistolGrip.important.bullethole.CFrame = torso.CFrame * CFrame.new(1.5, 1.04, -2.55) * CFrame.Angles(90, 0, 0)
				remote:FireServer("fire", script.Parent.PistolGrip.important.bullethole.CFrame)
				fire:Play()
			else
				remote:FireServer("fireblank")
			end
			wait(0.2)
			db = false
		end
	end
end)
1 Like

If you’re making a strictly fps game you can just make a part that constantly positions itself where the mouse hit, and as the mouse is always where the gun is pointed (im assuming) it would be easier.

yeah but I want to make it so you can physically see the bullet come out and shoot towards where your mouse is pointing, that way i can also customize things like range

i forgot to anchor the torso of my viewmodel

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