Animations change at night

I have been trying to figure out how to have animations swap between night and day ones but can’t seem to get it to work.
Can someone help me?

here is the code I have been testing it with

local model = script.Parent

while true do
    wait(0.1)
    if game.Lighting:GetMinutesAfterMidnight() > 6 * 00 then
        model.BaseAnimate.idle.Animation1.AnimationId = 12337881022
        model.BaseAnimate.idle.Animation2.AnimationId = 12337881022
    end
    if game.Lighting:GetMinutesAfterMidnight() > 18 * 60 then
        model.BaseAnimate.idle.Animation1.AnimationId = 12337888122
        model.BaseAnimate.idle.Animation2.AnimationId = 12337888122
    end
end

This script is running on server right?

you want to make sure script is being run in server since it is looking for server controlled object. I also think you set up the operator the wrong way. It should look like this:

if game.Lighting:GetMinutesAfterMidnight() > 6 * 00 then
        model.BaseAnimate.idle.Animation1.AnimationId = 12337881022
        model.BaseAnimate.idle.Animation2.AnimationId = 12337881022
    end
    if game.Lighting:GetMinutesAfterMidnight() < 18 * 60 then
        --should be "<" not ">"
        model.BaseAnimate.idle.Animation1.AnimationId = 12337888122
        model.BaseAnimate.idle.Animation2.AnimationId = 12337888122
    end```

Does not really seem to be working it just stays as the night animation and not the day one
i even made a script that works as the night animations and does not even swap at the chosen time

I was able to figure it out and get it to work

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.