So here is the issue I am seeing:
I am trying to make a pallbearer system that doesn’t involve seats or a dedicated cart, for caskets I have it rather solid but for some reason, the animations for the coffin setup are giving me issues. The animations do not sync up and the player positioning is even worse, I have done everything I know to do: Make sure the PNO is set to the primary player, use local scripts to change the player animations, and lock movement controls for other players so that they can’t influence the rig.
Is there anything I am missing? Ill set all the scripts below, tho be warned they are still spaghetti right now.
Main Control Script:
- Cedar Memorial Pall Bearer System (Server)
--- Created: 10/24/2023
---- Original Programer: Sterling_ODeaghaidh(10283957)
----------------------Globals-------------------------
Coffin = script.Parent
Event = Coffin.CoffinEvent
Players = Coffin.Players
IsCasket = Coffin.Casket.Value
UI = Coffin.CasketUI
--Names reference to side of casket the player is on and not which hand it is.
ArmsBack = "rbxassetid://5715692732"
ArmsFront = "rbxassetid://5715697224"
CasketRight = "rbxassetid://6583378359"
CasketLeft = "rbxassetid://6583439088"
CasketLeftUp = "rbxassetid://8992930432"
CasketRightUp = "rbxassetid://8993102505"
CasektRearUp = "rbxassetid://5715693857"
CasketLeftHearse = "rbxassetid://8993139479"
CasketRightHearse = "rbxassetid://8993164931"
CasketRearHearse = "rbxassetid://8993162016"
CasketRightDown = "rbxassetid://8993210827"
CasketLeftDown = "rbxassetid://8993237422"
CasketFrontDown = "rbxassetid://8993243991"
CoffinRightWaist = "rbxassetid://12921388041"
CoffinRightHigh = "rbxassetid://122959723623639"
CoffinRightLow = "rbxassetid://136291565595983"
CoffinLeftWaist = "rbxassetid://12921647645"
CoffinLeftHigh = "rbxassetid://100634982764541"
CoffinleftGround = "rbxassetid://136291565595983"
CoffinLeftShoulder = "rbxassetid://105251961264215"
CoffinRightShoulder = "rbxassetid://105251961264215"
---------------------Variables------------------------
LeadPlayer = nil
LeadInterlock = false
GroupInterlock = false
Active = true
GRP = 1128069
RNK = 7
Left = Coffin.Left
Right = Coffin.Right
Front = Coffin.Front
Back = Coffin.Back
-------------------Begin Program----------------------
-- Position Change
function SendCommand(Position)
Event:FireAllClients("ChangePosition")
end
-- PlayerManager
Players.ChildAdded:Connect(function(V)
if V.Value:IsA("Player") then
if V.Value:GetRankInGroup(GRP) >= RNK then
if LeadInterlock == false then
LeadInterlock = true
GroupInterlock = true
LeadPlayer = V.Value
local GUI = UI:Clone()
GUI.Parent = LeadPlayer.PlayerGui
GUI.CasketLocal.Enabled = true
end
else
if LeadInterlock == false and GroupInterlock == false then
LeadPlayer = V.Value
local GUI = UI:Clone()
GUI.Parent = LeadPlayer.PlayerGui
GUI.CasketLocal.Enabled = true
LeadInterlock = true
end
end
end
script.Parent.Parent.Attach.LinearVelocity.Enabled = true
script.Parent.Parent.Attach.LinearVelocity2.Enabled = true
V.Value.Character.Humanoid.WalkSpeed = 0
end)
----
Players.ChildRemoved:Connect(function(V)
if V.Value == LeadPlayer then
local CUI = LeadPlayer.PlayerGui:FindFirstChild("CasketUI")
if CUI then
CUI:Destroy()
end
----
for i, c in pairs(Players:GetChildren()) do
if c.Value:GetRankInGroup(GRP) >= RNK then
LeadInterlock = true
GroupInterlock = true
LeadPlayer = V.Value
local GUI = UI:Clone()
GUI.Parent = LeadPlayer.PlayerGui
GUI.CasketLocal.Enabled = true
else
LeadInterlock = false
GroupInterlock = false
end
end
---
if GroupInterlock == false and LeadInterlock == false then
local PLR = Players:FindFirstChildOfClass("ObjectValue")
if PLR then
LeadInterlock = true
LeadPlayer = PLR.Value
else
LeadInterlock = false
GroupInterlock = false
end
end
end
V.Value.Character.Humanoid.WalkSpeed = 16
for index, child in pairs(V.Value.Character.Humanoid:GetChildren()) do
if child:IsA("Animator") then
child:Destroy()
wait(.1)
local P = Instance.new("Animator")
P.Name = "Animator"
P.Parent = V.Value.Character.Humanoid
end
end
local PLR = Players:FindFirstChildOfClass("ObjectValue")
if not PLR then
print(1)
LeadInterlock = false
GroupInterlock = false
LeadPlayer = nil
script.Parent.Parent.Attach.LinearVelocity.Enabled = false
script.Parent.Parent.Attach.LinearVelocity2.Enabled = false
end
end)
-- Changer
Event.OnServerEvent:Connect(function(P,M,V1,V2,V3,V4)
if M == "RemovePlayer" then
local GU = P.PlayerGui:FindFirstChild("Animation Controller")
local GUi = P.PlayerGui:FindFirstChild("CasketUI")
if GU then
GU:Destroy()
end
if GUi then
GUi:Destroy()
end
for i, c in pairs(Players:GetChildren()) do
if c.Value == P then
c:Destroy()
end
end
end
----
if P == LeadPlayer then
if M == "Mid" then
if IsCasket == true then
Left.AnimationId = CasketLeft
else
Left.AnimationId = CoffinLeftWaist
end
if IsCasket == true then
Right.AnimationId = CasketRight
else
Right.AnimationId = CoffinRightWaist
end
if IsCasket == true then
Front.AnimationId = ArmsBack
end
if IsCasket == true then
Back.AnimationId = ArmsFront
end
script.Parent.Shoulder.Value = false
end
----
if M == "Up" then
if IsCasket == true then
Left.AnimationId = CasketLeftUp
else
Left.AnimationId = CoffinLeftHigh
end
if IsCasket == true then
Right.AnimationId = CasketRightUp
else
Right.AnimationId = CoffinRightHigh
end
if IsCasket == true then
Back.AnimationId = CasektRearUp
end
script.Parent.Shoulder.Value = false
end
----
if M == "Down" then
if IsCasket == true then
Left.AnimationId = CasketLeftDown
else
Left.AnimationId = CoffinleftGround
end
if IsCasket == true then
Right.AnimationId = CasketRightDown
else
Right.AnimationId = CoffinRightLow
end
if IsCasket == true then
Front.AnimationId = CasketFrontDown
end
script.Parent.Shoulder.Value = false
end
----
if M == "Hearse" then
if IsCasket == true then
Left.AnimationId = CasketLeftHearse
else
Left.AnimationId = CoffinLeftWaist
end
if IsCasket == true then
Right.AnimationId = CasketRightHearse
else
Right.AnimationId = CoffinRightWaist
end
if IsCasket == true then
Front.AnimationId = ArmsBack
end
if IsCasket == true then
Back.AnimationId = ArmsFront
end
script.Parent.Shoulder.Value = false
end
----
if M == "High" then
Left.AnimationId = CoffinLeftHigh
Right.AnimationId = CoffinRightHigh
script.Parent.Shoulder.Value = false
end
----
if M == "Shoulder" then
Left.AnimationId = CoffinLeftShoulder
Right.AnimationId = CoffinRightShoulder
script.Parent.Shoulder.Value = true
end
SendCommand()
end
end)
-- Loop
while true do task.wait(2)
if Coffin.Parent.Body:CanSetNetworkOwnership() then
if LeadPlayer ~= nil then
Coffin.Parent.Body:SetNetworkOwner(LeadPlayer)
else
Coffin.Parent.Body:SetNetworkOwnershipAuto()
end
end
end
Attachment Point Script:
isOn = false
Pause = .05
CurrentPlr = nil
script.Parent.ClickDetector.MouseClick:Connect(function(Plr)
if Plr.Character.Humanoid.RigType == Enum.HumanoidRigType.R15 then
if script.Parent.Parent.Parent.Attach.LinearVelocity.VectorVelocity.X == 0 and script.Parent.Parent.Parent.Attach.LinearVelocity.VectorVelocity.Z == 0 then
if CurrentPlr == nil then
CurrentPlr = Plr
Plr.Character.Humanoid.WalkSpeed = 10
local Script = script.Parent["Animation Controller"]:Clone()
local OV = Instance.new("ObjectValue")
local ATT = script.Parent:FindFirstChildOfClass("Attachment")
Script.Parent = Plr.PlayerGui
Script.Enabled = true
OV.Value = Plr
OV.Parent = script.Casket.Value.Players
OV.Name = "Player"
for i, c in pairs(script.Parent.Parent.Parent:GetDescendants()) do
if c:IsA("BasePart") then
c.Anchored = true
end
end
wait(.5)
if ATT.Name == "Left" then
if script.Parent.Parent.Casket.Value == true then
script.Parent.HingeConstraint.Attachment1 = Plr.Character.RightHand.RightGripAttachment
else
script.Parent.CoffinHinge.Attachment1 = Plr.Character.LeftHand.LeftGripAttachment
script.Parent.CoffinHinge1.Attachment1 = Plr.Character.RightHand.RightGripAttachment
end
elseif ATT.Name == "Right" then
if script.Parent.Parent.Casket.Value == true then
script.Parent.HingeConstraint.Attachment1 = Plr.Character.LeftHand.LeftGripAttachment
else
script.Parent.CoffinHinge.Attachment1 = Plr.Character.RightHand.RightGripAttachment
script.Parent.CoffinHinge1.Attachment1 = Plr.Character.LeftHand.LeftGripAttachment
end
end
wait(.5)
for i, c in pairs(script.Parent.Parent.Parent:GetDescendants()) do
if c:IsA("BasePart") then
c.Anchored = false
end
end
end
end
end
end)
script.Parent.Parent.Shoulder.Changed:Connect(function()
if script.Parent.Parent.Shoulder.Value == true then
script.Parent.HingeConstraint.Attachment0 = script.Parent.CoffinRightFront
script.Parent.CoffinHinge.Attachment1 = nil
script.Parent.CoffinHinge1.Attachment1 = nil
----
for _, Obj in pairs(script.Parent:GetChildren()) do
if Obj:IsA("Attachment") and Obj.Name == "Right" then
script.Parent.HingeConstraint.Attachment1 = CurrentPlr.Character.UpperTorso.LeftCollarAttachment
elseif Obj:IsA("Attachment") and Obj.Name == "Left" then
script.Parent.HingeConstraint.Attachment1 = CurrentPlr.Character.UpperTorso.RightCollarAttachment
end
end
else
script.Parent.HingeConstraint.Attachment0 = script.Parent:FindFirstChild(script.Parent["Animation Controller"].Side.Value)
for _, Obj in pairs(script.Parent:GetChildren()) do
if Obj:IsA("Attachment") and Obj.Name == "Right" then
if script.Parent.Parent.Casket.Value == true then
script.Parent.HingeConstraint.Attachment1 = CurrentPlr.Character.RightHand.RightGripAttachment
else
script.Parent.CoffinHinge.Attachment1 = CurrentPlr.Character.RightHand.RightGripAttachment
script.Parent.CoffinHinge1.Attachment1 = CurrentPlr.Character.LeftHand.LeftGripAttachment
end
elseif Obj:IsA("Attachment") and Obj.Name == "Left" then
if script.Parent.Parent.Casket.Value == true then
script.Parent.HingeConstraint.Attachment1 = CurrentPlr.Character.LeftHand.LeftGripAttachment
else
script.Parent.CoffinHinge.Attachment1 = CurrentPlr.Character.LeftHand.LeftGripAttachment
script.Parent.CoffinHinge1.Attachment1 = CurrentPlr.Character.RightHand.RightGripAttachment
end
end
end
end
end)
script.Parent.Parent.Players.ChildRemoved:Connect(function(O)
if O.Value == CurrentPlr then
CurrentPlr = nil
script.Parent.HingeConstraint.Attachment1 = script.Parent.HingeConstraint.Attachment0
script.Parent.CoffinHinge.Attachment1 = script.Parent.HingeConstraint.Attachment0
script.Parent.CoffinHinge1.Attachment1 = script.Parent.HingeConstraint.Attachment0
end
end)
Local Animation Control Script:
UIS = game:GetService("UserInputService")
anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Side.Value)
anim:Play()
script.Casket.Value.CoffinEvent.OnClientEvent:Connect(function(M)
if M == "ChangePosition" then
anim:Stop()
anim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Side.Value)
anim:Play()
end
end)
UIS.InputBegan:Connect(function(K,C)
if C == false then
if K.KeyCode == Enum.KeyCode.X then
script.Casket.Value.CoffinEvent:FireServer("RemovePlayer")
end
end
end)
Lead Player Control Script:
-- Cedar Memorial Pall Bearer System (Local)
--- Created: 10/24/2023
---- Original Programer: Sterling_ODeaghaidh(10283957)
----------------------Globals-------------------------
UI = script.Parent
Coffin = UI.Coffin.Value
Event = Coffin.CoffinEvent
Players = Coffin.Players
IsCasket = Coffin.Casket.Value
UIS = game:GetService("UserInputService")
---------------------Variables------------------------
movement = Vector3.new(0,0,0)
movement1 = Vector3.new(0,0,0)
-------------------Begin Program----------------------
-- Setup
if IsCasket then
UI.Frame.Neck.Visible = false
UI.Frame.High.Visible = false
else
UI.Frame.Neck.Visible = true
UI.Frame.High.Visible = true
end
-- Keybinds
UIS.InputBegan:Connect(function(inputObject,gameProcessedEvent)
if not gameProcessedEvent then
if inputObject.KeyCode == Enum.KeyCode.W or inputObject.KeyCode == Enum.KeyCode.Up then
movement = Vector3.new(5, movement.Y, movement.Z)
movement1 = Vector3.new(5, movement.Y, movement.Z)
end
if inputObject.KeyCode == Enum.KeyCode.S or inputObject.KeyCode == Enum.KeyCode.Down then
movement = Vector3.new(-5, movement.Y, movement.Z)
movement1 = Vector3.new(-5, movement.Y, movement.Z)
end
if inputObject.KeyCode == Enum.KeyCode.A or inputObject.KeyCode == Enum.KeyCode.Left then
movement = Vector3.new( movement.x, movement.y,-5)
movement1 = Vector3.new( movement.x, movement.y,5)
end
if inputObject.KeyCode == Enum.KeyCode.D or inputObject.KeyCode == Enum.KeyCode.Right then
movement1 = Vector3.new( movement.x, movement.y,-5)
movement = Vector3.new( movement.x, movement.y,5)
end
end
end)
---
UIS.InputEnded:connect(function(inputObject, gameProcessedEvent)
if not gameProcessedEvent then
if inputObject.KeyCode == Enum.KeyCode.W or inputObject.KeyCode == Enum.KeyCode.Up then
movement = Vector3.new(0, movement.Y, movement.Z)
movement1 = Vector3.new(0, movement.Y, movement.Z)
end
if inputObject.KeyCode == Enum.KeyCode.S or inputObject.KeyCode == Enum.KeyCode.Down then
movement = Vector3.new(0, movement.Y, movement.Z)
movement1 = Vector3.new(0, movement.Y, movement.Z)
end
if inputObject.KeyCode == Enum.KeyCode.A or inputObject.KeyCode == Enum.KeyCode.Left then
movement1 = Vector3.new( movement.x, movement.y,0)
movement = Vector3.new( movement.x, movement.y,0)
end
if inputObject.KeyCode == Enum.KeyCode.D or inputObject.KeyCode == Enum.KeyCode.Right then
movement1 = Vector3.new( movement.x, movement.y,0)
movement = Vector3.new( movement.x, movement.y,0)
end
end
end)
-- Buttons
UI.Frame.Low.MouseButton1Click:Connect(function()
Event:FireServer("Down")
end)
----
UI.Frame.Waist.MouseButton1Click:Connect(function()
Event:FireServer("Mid")
end)
----
UI.Frame.Up.MouseButton1Click:Connect(function()
Event:FireServer("Up")
end)
----
UI.Frame.High.MouseButton1Click:Connect(function()
Event:FireServer("High")
end)
----
UI.Frame.Neck.MouseButton1Click:Connect(function()
Event:FireServer("Shoulder")
end)
----
UI.Frame.HEearse.MouseButton1Click:Connect(function()
Event:FireServer("Hearse")
end)
spawn(function()
while script.Enabled == true do
game:GetService("RunService").RenderStepped:wait()
Coffin.Parent.Attach.LinearVelocity.VectorVelocity = movement
Coffin.Parent.Attach.LinearVelocity2.VectorVelocity = movement1
end
script:Destroy()
end)
Pictures to show the issue: