Animatable Book

I’m trying to make a tool animatable. The tool is a book, and when it’s activated, it’ll open and close.

I’ve tried using motor6Ds, but the position changes. I’ve used weld constraints AND motor6Ds, but that didn’t work for obvious reasons.

How would I do this?

i did one before, what i would recommend that when the tool is equipped, delete “RightGrip” in the right arm, and replace it with a Motor6D

something like this

local tool = script.Parent
local handle = tool:WaitForChild("Handle")

local currMotor6d : Motor6D = nil
local grip_connection : RBXScriptConnection = nil

local function findValidWeld(holder) : Weld
	for _, v in pairs(holder:GetDescendants()) do
		if v:IsA("Weld") and v.Name == "RightGrip" then
			return v
		end
	end
	
	return nil
end

tool.Equipped:Connect(function()
	local holder = tool.Parent
	local weld = findValidWeld(holder)
	
	if not weld then return end
	
	local parent = weld.Parent
	
	weld:Destroy()
	
	local motor = Instance.new("Motor6D")
	currMotor6d = motor
	motor.Name = "RightGrip"
	motor.C0 = CFrame.new(0, -1, 0) * CFrame.Angles(math.rad(-90), 0, 0)
	motor.C1 = tool.Grip or CFrame.identity
	
	motor.Part0 = parent
	motor.Part1 = handle
	
	motor.Parent = parent
	
	grip_connection = tool:GetPropertyChangedSignal("Grip"):Connect(function() --this changes the motor6d's C1 so it matches the new grip when its changed
		motor.C1 = tool.Grip or CFrame.identity
	end)
end)

tool.Unequipped:Connect(function()
	if grip_connection then
		grip_connection:Disconnect()
	end
	
	if currMotor6d then
		currMotor6d:Destroy()
		currMotor6d = nil
	end
end)

used this code for one of my games (not the same but similar)

for animation, you can parent the tool to your rig and in right arm, replace RightGrip (weld) with a motor6d with a plugin like reclass or copy every property from the weld to the motor6d
if it wanst what you were talking about then uh yeah idk

I’m sorry, but I lowkey forgot I made this topic, and I don’t need it anymore.

i just saw that it exists and decided to reply

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