Okay I have this script where when they equip something it will make their arms go to a certain CFrame. But each time it changes the Cfame... I need help lol

local Fire = game.ReplicatedStorage.Equip
local module = require(game.ReplicatedStorage.ModuleScript)
local hold = true
local a = -3.14

Fire.OnServerEvent:connect(function(plr,start,defr,defl)
	wait()
	local hasgun = Instance.new("BoolValue",plr.Character)
	hasgun.Name = "HasGun"
	hasgun.Value = true
	if hold and plr.Character.RepState.Value ~= "Prone" and plr.Character.RepState.Value ~= "Crouch" then
		if start.Parent.Name == "Pistol" then
			for i = 4,3,-1 do
				plr.Character.Torso["Right Shoulder"].C1 = defr * CFrame.Angles(a / -.65, -.3, 0)
				plr.Character.Torso["Left Shoulder"].C1 = defl * CFrame.Angles(a / -.65, .3, 0)
				wait(.1)
			end
		elseif start.Parent.Name == "AK47" then
			for i = 4,3,-1 do
				plr.Character.Torso["Right Shoulder"].C1 = defr * CFrame.Angles(a / -.67, -.3, 0)
				plr.Character.Torso["Left Shoulder"].C1 = defl * CFrame.Angles(a / -.67, .3, 0)
				wait(.1)
			end			
		end
	elseif hold and plr.Character.RepState.Value == "Crouch" then
		for i = 4,3,-1 do
			plr.Character.Torso["Right Shoulder"].C1 = defr * CFrame.Angles(a / -.67, -.3, 0)
			plr.Character.Torso["Left Shoulder"].C1 = defl * CFrame.Angles(a / -.67, .3, 0)
			wait(.1)
		end			
	end
end)

That's my script. Everything is as it should be, no errors but it changes for some reason, I have no random thing in it or anything to suggest why this is happneing

4 comments

0

Instead of using CFrames, you should consider using animations with :LoadAnimation(). You can make your own animation with the ROBLOX animation editor plugin, found here: https://www.roblox.com/Animation-Editor-item?id=144373835

0

Hey there, yeah I have tried animations before, but I've come too far with the CFrame to quit now. I'm just trying to work out why it kind of makes it random each time, like it makes it near enough the same but sometimes one of the arms is too high or too low, idk why

0

Maybe it's that one of the arms is currently in the swinging arm default animation.

0

I'm usin a custom character, that's not the case