Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[SOLVED] Why does my aiming system CFrame not go back to its orignal place?

So the problem is that my aiming system is not working like it's supposed to. If I press mouse2, I will aim, but when I put my mouse up, it decides not to go out of the aiming and just stay in the aiming position.

Aim part of the script (local):

mouse.Button2Down:Connect(function()
	if currentWeaponType ~= "Melee" then
		aiming = true
	end
end)

mouse.Button2Up:Connect(function()
	aiming = false
end)


runService.RenderStepped:Connect(function()
	if aiming == true and currentWeaponType ~= "Melee" then
		aimCFrame = aimCFrame:Lerp(CFrame.new(weapon:GetAttribute("AimCFrame")), .25)
		camera.FieldOfView = weapon:GetAttribute("AimFOV")
	elseif aiming == false then
		aiming = aimCFrame:Lerp(CFrame.new(0,0,0), .25)
		camera.FieldOfView = 70
	end
	
	weapon:SetPrimaryPartCFrame(camera.CFrame * CFrame.new(0,-1,0) * aimCFrame)
end)

When putting a print in the button2up event it will print, but the arm will not go back to its original position.

Thanks for reading!

1 comment

0

Instead of trying the get the attribute, try setting it manually or maybe there is something attribute.

1 answer

I fixed it. I accidentally put the aiming variable instead of aimCFrame on line 17. Wasn't worth the entire hour I tried to fix this very simple mistake.

This discussion is preserved as it was. New answers, comments, and votes are closed.