I have this error for whenever someone sits on a ‘Seat’ object, the pose that has been set for the seat keeps playing even after the player has gotten up from it.
Error code: “Argument 1 missing or nil”
I’ve surfed through the internet for some solutions but I’ve found none for this specific error.
Here is the script I use:
seat = script.Parent
-- Name of the folder that contains the sitting poses
local SITTING_POSES_FOLDER_NAME = "SittingPoses"
function added(child)
if child.ClassName == "Weld" then
local character = child.Part1.Parent
if character:FindFirstChild("Humanoid") then
local posesFolder = game.Workspace:FindFirstChild(SITTING_POSES_FOLDER_NAME)
if posesFolder and posesFolder:IsA("Folder") then
local poses = posesFolder:GetChildren()
local sittingPose = poses[math.random(#poses)]
character.Humanoid:LoadAnimation(sittingPose):Play()
end
end
end
end
function removed(child)
if child.ClassName == "Weld" then
local character = child.Part1.Parent
if character:FindFirstChild("Humanoid") then
character.Humanoid:LoadAnimation():Stop()
end
end
end
seat.ChildAdded:Connect(added)
seat.ChildRemoved:Connect(removed)
This script is supposed to play a random sitting pose every time someone sits on it, those animations are randomly chosen out from a folder.
The error is said to be on the 24th line, though I’m not sure how to fix it.