Help / Character Pauses When Summoning Stand / May Be Related To Motor6D

This is a support category for asking questions about how to get something done on the Roblox websites or how to do something on Roblox applications such as Roblox Studio.

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!|
    Ans: I want the character to not pause when i summon the stand

  2. What is the issue? Include screenshots / videos if possible!
    Ans: The character pauses when i summon the stand

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Ans: Tried using weld constraints but that messed everything up

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Code:
Stands Module:

local ServerStorage = game:GetService("ServerStorage")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")

local EventsFolder = ReplicatedStorage:WaitForChild("Events")
local StandsFolder = ServerStorage:WaitForChild("Stands")
local StandsCloneFolder = ServerStorage:WaitForChild("StandsClone")
local StandsInfoFolder = ServerStorage:WaitForChild("StandsInfo")

local SummonStandEvent = EventsFolder:WaitForChild("SummonStand")

local API
local Stands = {
	ErrorCodes = {
		NOPLAYER = "No Player Was Given.",
		NOCHARACTER = "Player's Character Wasn't Found.",
		NOROOTPART = "Player's RootPart Wasn't Found.",
		NOSTANDROOTPART = "Stand's Root Part Not Found. Notify The Owner Or Devs About This.",
		NOSTANDANIMATION = "Stand's Animation Not Found. Notify The Owner Or Devs About This.",
		STANDNOTFOUND = "Stand Wasn't Found.",
		MOTOR6DNOTFOUND = "Motor6D Wasn't Found.",
		ANIMATIONFOLDERNOTFOUND = "Animation Folder Wasn't Found.",
	},
}

local function SummonStand(player: Player, realstats: Folder, StandValue: StringValue, StandSummoned: BoolValue)
	local Character = player.Character or player.CharacterAdded:Wait()
	local RootPart = Character.HumanoidRootPart
	local Stand
	local StandAnimations

	if not player then
		return Stands.ErrorCodes.NOPLAYER
	end
	if not Character then
		return Stands.ErrorCodes.NOCHARACTER
	end
	if not RootPart then
		return Stands.ErrorCodes.NOROOTPART
	end

	for _, randomstand in StandsFolder:GetChildren() do
		if randomstand.Name ~= StandValue.Value then
			continue
		end
		Stand = randomstand:Clone()
		break
	end
	for _, randomstandfolder in StandsInfoFolder:GetChildren() do
		if randomstandfolder.Name ~= StandValue.Value then
			continue
		end
		StandAnimations = randomstandfolder.Animations
		break
	end

	if not Stand then
		return Stands.ErrorCodes.STANDNOTFOUND
	end
	if not StandAnimations then
		return Stands.ErrorCodes.NOSTANDANIMATION.. " Folder: " ..Stand.Name
	end
	if not StandAnimations.Idle then
		return Stands.ErrorCodes.NOSTANDANIMATION.. " Animation: Idle"
	end

	local StandRootPart = Stand.PrimaryPart
	if not StandRootPart then
		return Stands.ErrorCodes.NOSTANDROOTPART
	end

	Stand.Parent = StandsCloneFolder

	local Motor6D = Instance.new("Motor6D", RootPart)
	Motor6D.Part0 = RootPart
	Motor6D.Part1 = StandRootPart
	Motor6D.C1 = CFrame.new(0, 0, 0)

	for _, part in Stand:GetChildren() do
		if part.Name == "HumanoidRootPart" then
			continue
		end
		if part:IsA("BasePart") or part:IsA("MeshPart") then
			part.Transparency = 1
		end
	end

	local Animator = Stand.Humanoid.Animator
	local LoadedIdle = Animator:LoadAnimation(StandAnimations["Idle"])
	LoadedIdle:Play()

	Stand.Parent = Character

	task.spawn(function()
		for _, part in Stand:GetChildren() do
			if part.Name == "HumanoidRootPart" then
				continue
			end
			if part:IsA("BasePart") or part:IsA("MeshPart") then
				task.spawn(function()
					for i = 1, 0, -0.1 do
						part.Transparency = i
						task.wait(0.00025)
					end
					part.Transparency = 0
				end)
			end
		end
	end)

	local targetC1 = CFrame.new(4, -3, 0)
	local duration = 0.75
	local elapsedTime = 0

	while elapsedTime < duration do
		elapsedTime += RunService.Heartbeat:Wait()
		local alpha = math.min(elapsedTime / duration, 1)
		Motor6D.C1 = Motor6D.C1:Lerp(targetC1, alpha)
	end

	StandSummoned.Value = true

	return "Summoned Stand: " ..StandValue.Value
end

local function RetractStand(player: Player, realstats: Folder, StandValue: StringValue, StandSummoned: BoolValue)
	local Character = player.Character or player.CharacterAdded:Wait()
	local RootPart = Character.HumanoidRootPart
	local Stand

	if not player then
		return Stands.ErrorCodes.NOPLAYER
	end
	if not Character then
		return Stands.ErrorCodes.NOCHARACTER
	end
	if not RootPart then
		return Stands.ErrorCodes.NOROOTPART
	end

	Stand = Character:FindFirstChild(StandValue.Value)

	if not Stand then
		return Stands.ErrorCodes.STANDNOTFOUND
	end

	local Animator = Stand.Humanoid.Animator
	local AnimTracks = player.Character.Humanoid:GetPlayingAnimationTracks()

	for _, animation in ipairs(AnimTracks) do
		animation:Stop()
	end

	local Motor6D = RootPart:FindFirstChild("Motor6D")
	if not Motor6D then
		return Stands.ErrorCodes.MOTOR6DNOTFOUND
	end

	task.spawn(function()
		for _, part in Stand:GetChildren() do
			if part:IsA("BasePart") or part:IsA("MeshPart") then
				task.spawn(function()
					for i = 0, 1, 0.05 do
						part.Transparency = i
						task.wait(0.0005)
					end
				end)
			end
		end
	end)

	local targetC1 = CFrame.new(0, 0, 0)
	local duration = 0.75
	local elapsedTime = 0

	while elapsedTime < duration do
		elapsedTime += RunService.Heartbeat:Wait()
		local alpha = math.min(elapsedTime / duration, 1)
		Motor6D.C1 = Motor6D.C1:Lerp(targetC1, alpha)
	end

	Stand:Destroy()
	Motor6D:Destroy()

	StandSummoned.Value = false

	return "Retracted Stand: " .. StandValue.Value
end

local function HookStandEvent()
	SummonStandEvent.OnServerInvoke = function(player: Player)
		local realstats = player:FindFirstChild("realstats")
		local StandValue = realstats:FindFirstChild("Stand")
		local StandSummoned = realstats:FindFirstChild("StandSummoned")

		if not realstats then
			return API.ErrorCodes.REALSTATSNOTFOUND
		end
		if not StandValue then
			return API.ErrorCodes.VALUENOTFOUND.. " Value: Stand"
		end
		if not StandSummoned then
			return API.ErrorCodes.VALUENOTFOUND.. " Value: StandSummoned"
		end

		local responce

		if StandSummoned.Value then
			responce = RetractStand(player, realstats, StandValue, StandSummoned)
		else
			responce = SummonStand(player, realstats, StandValue, StandSummoned)
		end

		if not responce then
			return "Stands Module Is Broken, Report AS FAST To Biraru Or A Dev."
		end

		return responce
	end
end

function Stands.Main(api)
	if not api then
		error("API not supplied")
	end
	API = api
end

function Stands.Init()
	HookStandEvent()
end

return Stands`

Players Module:


local API
local Player = {}

function Player.Main(api)
	if not api then
		error("API not supplied")
	end
	API = api
end

function Player.Init()
	Players.PlayerAdded:Connect(function(player: Player)
		local leaderstats = Instance.new("Folder", player)
		leaderstats.Name = "leaderstats"
		local realstats = Instance.new("Folder", player)
		realstats.Name = "realstats"
		local StandValue = Instance.new("StringValue", realstats)
		StandValue.Name = "Stand"
		StandValue.Value = "Qualify"
		local StandSummonedValue = Instance.new("BoolValue", realstats)
		StandSummonedValue.Name = "StandSummoned"
	end)
end

return Player