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

How do I make CFrame changes overwrite animations and tools?

I am decently new to CFrames and completely new at CFrame animation. I couldn't find any tutorials on how to do CFrame animations so I used the animation plugin to make an animation then just printed the .C1 of all the character joints for each frame and put them in a table. Then I just had a for loop set my characters joints to those when you click with a tool equipped. The animation works, but the problem is any animations that play while it is playing the CFrame animation play over it. So if the player jumps their arms flail and their feet pull pack. And because the player has a tool equipped their arm is extended and its CFrame doesn't change.

Here is the script (minus the cframes because question was over 10,000 characters and would not post)

local player = game.Players.LocalPlayer
local db = true--debug variable
local dw = 1
if db then--if in debug mode make things pause for 5 times as long
	dw = 5
end
local root = {}--table of cframes for RootJoint
local lhip = {}--table of cframes for Left Hip
local rhip = {}--table of cframes for Right Hip
local lshoulder = {}--table of cframes for Left Shoulder
local rshoulder = {}--table of cframes for Right Shoulder
function DJ()
	local tool = Instance.new("Tool", player:WaitForChild("Backpack"))
	tool.Name = "DJ Booth"
	tool.GripPos = Vector3.new(0,1,0)
	local suitcase = Instance.new("Part",tool)
	suitcase.Name = "Handle"
	suitcase.Size = Vector3.new(2,2,0.5)
	suitcase.CanCollide = true
	local mesh = Instance.new("SpecialMesh",suitcase)
	mesh.MeshId = "rbxassetid://442477818"
	mesh.TextureId = "rbxassetid://442477819"
	mesh.Scale = Vector3.new(5,5,5)
	local clicked = false
	tool.Equipped:connect(function(Mouse)
		Mouse.Button1Down:connect(function()
			if clicked == false then
				--clicked = true
				--play animation
				if player.Character:FindFirstChild("Humanoid") then
					if player.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
						player.Character.HumanoidRootPart.Anchored = true
						local torso = player.Character.HumanoidRootPart.RootJoint
						local rightarm = player.Character.Torso["Right Shoulder"]
						local leftarm = player.Character.Torso["Left Shoulder"]
						local rightleg = player.Character.Torso["Right Hip"]
						local leftleg = player.Character.Torso["Left Hip"]
						local speed = player.Character.Humanoid.WalkSpeed
						player.Character.Humanoid.WalkSpeed = 0
						for i=1,20 do
							wait(.05*dw)
							torso.C1 = root[i]
							leftleg.C1 = lhip[i]
							rightleg.C1 = rhip[i]
							leftarm.C1 = lshoulder[i]
							rightarm.C1 = rshoulder[i]
						end
						local j = 20
						for i=1,20 do
							wait(.05*dw)
							torso.C1 = root[j]
							leftleg.C1 = lhip[j]
							rightleg.C1 = rhip[j]
							leftarm.C1 = lshoulder[j]
							rightarm.C1 = rshoulder[j]
							j=j-1
						end
						player.Character.HumanoidRootPart.Anchored = false
						player.Character.Humanoid.WalkSpeed = speed
					else

					end
				end
				--build dj booth
			end
		end)
	end)
end
player.CharacterAdded:connect(function()
	DJ()
end)
wait(1)
if player.Character then
	if player.Character:FindFirstChild("DJ Booth") == nil and player.Backpack:FindFirstChild("DJ Booth") == nil then
		DJ()
	end
end

So how would I temporarily disable the player's animations and make the player's hand not extend with the tool equipped? I know I could use a HopperBin but those are depreciated.

2 answers

✓ Accepted answer

Remove 'Animator' inside the Humanoid of a character. It's basically the animation core. Then, do:

animator = Instance.new('Animator',humanoid)

to add it back. Hope I've helped!

2 comments

0

Yes it helped, but it only solved half of the problem.

0

Check my post below to see the rest of the problem.

OK so, my script now disables the animate script while my animation plays so it doesn't get overwritten. However, there is still the problem of how the tool makes the player's arm extend. I have it set to unequip all the player's tools with :UnequipTools() (hoping the player's arm would return to its normal position) and then I do tool:Destroy(). But then player's arm gets permanently stuck pointing forward. For some reason if you :Destroy() the tool while the click function is running (even from another script) the players' arm's default position is set to pointing straight forward.

3 comments

0

Add it back? or does that not work

0

No that does not work. For some reason is you delete or unequip the tool when that function is running the players arm is stuck in that position even if another tool is equiped. I am working on a solution i think might work

0

I just removed the handle from the tool and welded it to the player's arm so their arm doesn't extend.

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