Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Diferent animations to play on Seat not working and playing only one of them?

Asked by 3 years ago
Edited 3 years ago

I wanted to make diferent animations on each seat but they play only one of the animations this is the script i used and i dont know why only plays one and it dont show nothing of error on the output (Got part of it on other question)

local Players = game:GetService("Players") -- Our player service to use the PlayerAdded & CharacterAdded events.

local Seats = {
    [workspace.Seats.Seat] = 5325253550
}

local Seats2 = {
    [workspace.SeatUpsideDown] = 5336839197
}


local Seats3 = {
    [workspace.SeatTwo] = 5336861798
}

-- For each seat as the key, the value will the animation you want to play

Players.PlayerAdded:Connect(function(Player) -- On player added
    Player.CharacterAdded:Connect(function(Character) -- When character is added
    local Animation = Character:FindFirstChild('SitAnim', true) -- Finding the sit animation in the character
    local Humanoid = Character.Humanoid -- So we can use the GetPropertyChangedSignal

    Humanoid:GetPropertyChangedSignal('SeatPart'):Connect(function()
     local AnimationValue = Seats[Humanoid.SeatPart] -- if the part exists in the table as a key
     if not AnimationValue then  -- if it's not then we'll set it to our idle animation
        Animation.AnimationId = ('rbxassetid://5325253550') 
       else -- else if the animation does exist then it'll set to it's value that's in the table
        Animation.AnimationId = ('rbxassetid://2506281703')
      end
            end)  

            Humanoid:GetPropertyChangedSignal('SeatPart'):Connect(function()
     local AnimationValue = Seats2[Humanoid.SeatPart] -- if the part exists in the table as a key
     if not AnimationValue then  -- if it's not then we'll set it to our idle animation
        Animation.AnimationId = ('rbxassetid://5336839197') 
       else -- else if the animation does exist then it'll set to it's value that's in the table
        Animation.AnimationId = ('rbxassetid://2506281703')
      end
            end)

            Humanoid:GetPropertyChangedSignal('SeatPart'):Connect(function()
     local AnimationValue = Seats3[Humanoid.SeatPart] -- if the part exists in the table as a key
     if not AnimationValue then  -- if it's not then we'll set it to our idle animation
        Animation.AnimationId = ('rbxassetid://5336861798') 
       else -- else if the animation does exist then it'll set to it's value that's in the table
        Animation.AnimationId = ('rbxassetid://2506281703')
      end
    end)      
   end)
end)

Answer this question