I’ve been trying to figure out how I can put my sitting animations that I made and override the default animation. I tried ILurd’s script and it didn’t work. What could I fix?
local seat = script.Parent --Link this to the seat
local playingAnim
local newAnim = Instance.new('Animation')
newAnim.AnimationId = 'rbxassetid://'..sitAnim
seat.Changed:Connect(function(property)
if property == 'Occupant' then
local occupant = seat.Occupant
if not occupant then if playingAnim then playingAnim:Stop() return end end
playingAnim = occupant:LoadAnimation(newAnim)
playingAnim:Play()
end
end)
So I changed the script, set the animation priority to action, set it on loop too and it didn’t work. I don’t understand what’s wrong should the script be looking like this?
local seat = script.Parent --Link this to the seat
local playingAnim
local newAnim = Instance.new('Animation')
newAnim.AnimationId = 'rbxassetid://'..sitAnim
seat:GetPropertyChangedSignal("Occupant"):Connect(function(property)
if property == 'Occupant' then
local occupant = seat.Occupant
if not occupant then if playingAnim then playingAnim:Stop() return end end
playingAnim = occupant:LoadAnimation(newAnim)
playingAnim:Play()
end
end)
--solution
so which lines of code do i delete? Everything after if property == 'Occupant' then ? Not including end. Or which lines of code do I delete?
local seat = script.Parent --Link this to the seat
local playingAnim
local newAnim = Instance.new('Animation')
newAnim.AnimationId = 'rbxassetid://'..sitAnim
seat:GetPropertyChangedSignal("Occupant"):Connect(function(property)
if property == 'Occupant' then
local occupant = seat.Occupant
if not occupant then if playingAnim then playingAnim:Stop() return end end
playingAnim = occupant:LoadAnimation(newAnim)
playingAnim:Play()
end
end)
--solution```
playingAnim = occupant:LoadAnimation(newAnim)
seat:GetPropertyChangedSignal("Occupant"):Connect(function(property)
if property == 'Occupant' then
local occupant = seat.Occupant
if occupant ~= nil then
playingAnim:Play()
if occupant == nil then
playingAnim:Stop()
end
end
end
end)
local seat = script.Parent --Link this to the seat
local playingAnim
local newAnim = Instance.new('Animation')
newAnim.AnimationId = 'rbxassetid://'..sitAnim
seat:GetPropertyChangedSignal("Occupant"):Connect(function(property)
if property == 'Occupant' then
local occupant = seat.Occupant
if playingAnim == nil then
playingAnim = occupant:LoadAnimation(newAnim)
if occupant ~= nil then
playingAnim:Play()
if occupant == nil then
playingAnim:Stop()
end
end
end
end)
Sorry about all the questions but where do i put the animation id again? In the ‘rbxassetid://’ or should i make a variable for it. Something like sitAnim = 21414
property is giving me an error and it doesn’t work i don’t know whats going on
local playingAnim
local newAnim = Instance.new('Animation')
local sitAnim = 28488254
local newAnim = Instance.new('Animation')
newAnim.AnimationId = 4877060179
newAnim.AnimationId = 'rbxassetid://'..sitAnim
seat:GetPropertyChangedSignal("Occupant"):Connect(function(property)
end)
if property == 'Occupant' then
local occupant = seat.Occupant
if playingAnim == nil then
playingAnim = occupant:LoadAnimation(newAnim)
if occupant ~= nil then
playingAnim:Play()
if occupant == nil then
playingAnim:Stop()
end
end
end
end```
local seat = script.Parent
local playingAnim
local newAnim = Instance.new('Animation', game.Workspace)
local sitAnim = 28488254
newAnim.AnimationId = sitAnim
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local occupant = seat.Occupant
if playingAnim == nil then
playingAnim = occupant:LoadAnimation(newAnim)
if occupant ~= nil then
playingAnim:Play()
if occupant == nil then
playingAnim:Stop()
end
end
end
end)
I am pretty sure this will work, btw ur parameter “property”, was equal to nill