Im making a script for all the chairs inside to play animations when you sit in them but it wont work there all in a folder and it wont work.
Heres the script
repeat wait() until game:IsLoaded()
local chairs = workspace.Map.Insidebuilding.Chairs
local seatAnim = script:WaitForChild("SitAnimation1")
for _, v in pairs(chairs:GetChildren()) do
v.Chair.chair.seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local hum = v.Chair.chair.Occupant
if hum then
local LoadedAnim = hum:LoadAnimation(seatAnim)
local Connection
LoadedAnim:Play()
Connection = hum:GetPropertyChangedSignal("Sit"):Connect(function()
if hum.Sit == false then
LoadedAnim:Stop()
end
end)
end
end)
end
There are no errors and the animation is made by my group for the group game.
This is probably do to the fact that you are using a roblox seat. When you sit on them they weld the character to the seat (making it so it prevents the animation).
If i remove that it gives me this error: 21:00:59.067 Chair is not a valid member of Model “Workspace.Map.Insidebuilding.Chairs.Chair” - Server - SitAnimation1:7
Also @keith_220 i removed the repeat wait() until game:IsLoaded() like @Pat_WasTaken and it printed but it errored
Workspace.Map.Insidebuilding.Chairs:WaitForChild(“Chair”) add a wait for child. EDIT: also make sure that the Chair instance is a child of Chairs
ANOTHER EDIT: v.Chair.chair.seat:GetPropertyChangedSignal(“Occupant”):Connect(function()
local hum = v.Chair.chair.Occupant
I also realized there is two different seat references. first you do v.Chair.chair.seat then you do v.Chair.chair.Occupant. you are refering to two different objects here
Workspace.Map.Insidebuilding.Chairs:WaitForChild(“Chair”) not Workspace.Map.Insidebuilding.Chairs.Chair:WaitForChild(“Chair”) EDIT: also refer to my edit in my other reply
Where am i suspose to be putting this at? I cant put it at the chairs varible because its a for loop and it will get the children of the chair itself also i dont really understand what you said in the other reply