I’m working with animations in a game, and some of these animations require a custom rig and some don’t. Mind you the custom rig literally only has 2 parts different so it doesn’t warrant me changing the default rig, as its only needed sometimes. When the player loads I have it trying to set these custom parts into the players rig, and use motor6d’s to do so. That currently looks like this:
game.Players.PlayerAdded:Connect(function(addedPlayer)
addedPlayer.CharacterAdded:Connect(function(addedCharacter)
local laPart = game.ReplicatedStorage.gameAssets.LA:Clone()
local raPart = game.ReplicatedStorage.gameAssets.RA:Clone()
laPart.CFrame = addedCharacter.LeftHand.CFrame * CFrame.new(0, -3, 0)
raPart.CFrame = addedCharacter.RightHand.CFrame * CFrame.new(0, -3, 0)
local lamotor6 = Instance.new("Motor6D")
lamotor6.Name = "LA"
lamotor6.Part0 = addedCharacter.LeftHand
lamotor6.Part1 = laPart
lamotor6.Enabled = true
lamotor6.Parent = addedCharacter.LeftHand
local ramotor6 = Instance.new("Motor6D")
ramotor6.Name = "RA"
ramotor6.Part0 = addedCharacter.RightHand
ramotor6.Part1 = raPart
ramotor6.Enabled = true
ramotor6.Parent = addedCharacter.RightHand
laPart.Parent = addedCharacter
raPart.Parent = addedCharacter
end)
end)
On top of this, I decided that due to the unpredictability I would do a check when players get on a base to readd it. That also does not work as you can see from this:
local batterRitual
local batterStance
local batterDebounce = false
workspace.stadiumTemplate.Infield.Bases["Home Plate"].Center.Touched:Connect(function(touch)
if not batterDebounce then
batterDebounce = true
if game.ReplicatedStorage.gameData.positionData.batterPlayer.Value == nil then
if touch.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(touch.Parent)
if player and player.Character then
batterRitual = player.Character.Humanoid:LoadAnimation(createAnimation("rbxassetid://5058012828", player))
batterStance = player.Character.Humanoid:LoadAnimation(createAnimation("rbxassetid://5058022763", player))
batterStance.Looped = true
game.ReplicatedStorage.gameData.positionData.batterPlayer.Value = player
player.Character.Humanoid.WalkSpeed = 0
player.Character.Humanoid.JumpPower = 0
wait(.1)
if player.Character:FindFirstChild("LA") and not player.Character:FindFirstChild("RA") then
-- This bit does not like working
local laPart = game.ReplicatedStorage.gameAssets.LA:Clone()
local raPart = game.ReplicatedStorage.gameAssets.RA:Clone()
laPart.CFrame = player.Character.LeftHand.CFrame * CFrame.new(0, -3, 0)
raPart.CFrame = player.Character.RightHand.CFrame * CFrame.new(0, -3, 0)
local lamotor6 = Instance.new("Motor6D")
lamotor6.Name = "LA"
lamotor6.Part0 = player.Character.LeftHand
lamotor6.Part1 = laPart
lamotor6.Enabled = true
lamotor6.Parent = player.Character.LeftHand
local ramotor6 = Instance.new("Motor6D")
ramotor6.Name = "RA"
ramotor6.Part0 = player.Character.RightHand
ramotor6.Part1 = raPart
ramotor6.Enabled = true
ramotor6.Parent = player.Character.RightHand
laPart.Parent = player.Character
raPart.Parent = player.Character
end
if game.ReplicatedStorage.playerData[player.UserId].batHand.Value == "Right" then
local batClone = game.ReplicatedStorage.gameAssets.Bat:Clone()
batClone.Parent = player.Character
batClone.CFrame = player.Character.LA.CFrame
player.Character.LA.Bat.Part1 = batClone
player.Character.HumanoidRootPart.CFrame = workspace.stadiumTemplate.Infield.Bases["Home Plate"].Center.CFrame * CFrame.new(-5, 4, 0) * CFrame.Angles(0, math.rad(-90), 0)
else
local batClone = game.ReplicatedStorage.gameAssets.Bat:Clone()
batClone.Parent = player.Character
batClone.CFrame = player.Character.RA.CFrame
player.Character.RA.Bat.Part1 = batClone
player.Character.HumanoidRootPart.CFrame = workspace.stadiumTemplate.Infield.Bases["Home Plate"].Center.CFrame * CFrame.new(5, 4, 0) * CFrame.Angles(0, math.rad(90), 0)
end
wait(.4)
player.Character.HumanoidRootPart.Anchored = true
batterRitual.Stopped:Connect(function()
batterStance:Play()
end)
batterRitual:Play()
end
end
end
end
end)
What might I be doing to cause the Motor6d’s to disappear with my parts. The code itself isn’t erroring unless the custom rig bits held together via motor6d’s aren’t there. However this issue only occurs sometimes and I can’t live with this unpredictability.
Any help would be appreciated!