Throne Model Tween Moving Parts All To Same Position

Hello,
Recently I made a script that tweens a throne when the player hits the emote button up under them. However, it has come to my attention that the throne is not tweening properly and all the parts are bunched up and weird. Screenshots are attached below
imagethrone


Could anyone help me fix this? Script is attached below

button6.MouseButton1Click:Connect(function()
	local newAnim1 = Instance.new('Animation')
	local animid1 = 78505983054829
	newAnim1.AnimationId = "http://www.roblox.com/asset/?id=" .. tostring(animid1)

	local player = game:GetService("Players").LocalPlayer
	local character = player.Character or player.CharacterAdded:Wait()

	local humanoid = character:WaitForChild("Humanoid")
	local animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid)
	if not animstart then
		if  ANIMPLAYING==true then return end
		local playingAnim1 = animator:LoadAnimation(newAnim1)
		playingAnim1:Play()
		humanoid.WalkSpeed=0
		animstart = true
		-- Services
		local TweenService = game:GetService("TweenService")
		local ReplicatedStorage = game:GetService("ReplicatedStorage")
		local Players = game:GetService("Players")

		local function cloneAndTweenModel()
			-- Get the player
			local player = Players.LocalPlayer
			if not player then
				warn("No local player found.")
				return
			end

			local character = player.Character or player.CharacterAdded:Wait()
			local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
			if not humanoidRootPart then
				warn("No HumanoidRootPart found.")
				return
			end

		
			local modelTemplate = ReplicatedStorage:FindFirstChild("Throne")
			if not modelTemplate then
				warn("Model 'Throne' not found in ReplicatedStorage.")
				return
			end

			local clonedModel = modelTemplate:Clone()
			clonedModel.Parent = workspace 

			
			local offset = Vector3.new(0, 5, -10)
			for _, part in ipairs(clonedModel:GetDescendants()) do
				if part:IsA("BasePart") then
					
					if part:IsA("MeshPart") then
					
						part.Position = humanoidRootPart.Position + offset
					else
						
						part.CFrame = humanoidRootPart.CFrame * CFrame.new(offset)
					end
				end
			end

			
			local tweenInfo = TweenInfo.new(
				2, -- Time in seconds
				Enum.EasingStyle.Linear, 
				Enum.EasingDirection.InOut, 
				0, 
				false, 
				0 
			)

			local goalOffset = Vector3.new(0, 20, 0) 

			
			for _, part in ipairs(clonedModel:GetDescendants()) do
				if part:IsA("BasePart") then
					if part:IsA("MeshPart") then
					
						local goalPosition = part.Position + goalOffset
						local tween = TweenService:Create(part, tweenInfo, { Position = goalPosition })
						tween:Play()
					else
					
						local goalCFrame = part.CFrame + goalOffset
						local tween = TweenService:Create(part, tweenInfo, { CFrame = goalCFrame })
						tween:Play()
					end
				end
			end
		end

		-- Run the function
		cloneAndTweenModel()
	end
	end)
-- Get the UserInputService
local UserInputService = game:GetService("UserInputService")

-- Define the function to call when the space bar is pressed
local function onSpaceBarPressed()
	local player = game:GetService("Players").LocalPlayer
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:WaitForChild("Humanoid")

	if not humanoid then return end
	if not animstart then return end

	-- Stop all animations
	for _, track in ipairs(humanoid:GetPlayingAnimationTracks()) do
		track:Stop()
		humanoid.WalkSpeed=50
	end
	animstart = false -- Reset animstart after stopping animations
end

-- Connect the function to the InputBegan event
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if not gameProcessed and input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.Space then
        onSpaceBarPressed()
    end
end)

Its because your setting all the parts position to the same position, the chair has different positions for legs and the seat itself, try grouping the chair and add a script to weld it all together and just tween the CFrame of it.

how would i add a script to weld it

Give the model a PrimaryPart and Tween that one exclusively, Welding is not necesary unless you want the player to move during the emote, if that’s the case you do need to weld it, weld the entire model together and then the HumanoidRootPart to the Model

I’d recommend welding it before hand (i don’t know how to make a Weld script, CFrames are just magical), you’ll be able to find one easily though

1 Like