I’m trying to make an animation play when you ride your bike in my game.
I’m using this script:
game.ReplicatedStorage.BikeAni.OnClientEvent:Connect(function()
local Animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Animation)
Animation:Play()
end)
--I know loading it without the Animator is deprecated but the API article lacks information...
I know the event fires and is received and I get no output errors but is there a reason why it isn’t playing?
This is the server script (It checks if the player owns the vehicle as well):
seat.Changed:Connect(function(plr)
if seat.Occupant then
if seat.Occupant.Name ~= Owner then
local humanoid = seat.Occupant
if humanoid then
Player = game:GetService("Players"):GetPlayerFromCharacter(humanoid.Parent)
Character = humanoid.Parent
if Player then
seat:SetNetworkOwner(Player)
seat.Occupant.Jump = true
end
end
elseif seat.Occupant.Name == Owner then
local humanoid = seat.Occupant
Driving = true
local Ani = humanoid:LoadAnimation(script.Animation)
Ani:Play()
end
end
end)
local Ani = humanoid:LoadAnimation(script.Animation)
Can you double check to make sure that the animation you’re trying to load is valid? You could export it as an ID, and also I think you might also need to disable the Animate script as well in your Local Event
--ServerSide
if seat.Occupant then
local HumSeat = seat.Occupant
local Char = HumSeat.Parent
local SeatPlayer = game:GetService("Players"):GetPlayerFromCharacter(Char)
game.ReplicatedStorage.BikeAni:FireClient(SeatPlayer)
end
But this one doesn’t play the animation:
--ClientSide
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:Wait()
end
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://6190468193"
local AnimationTrack = animator:LoadAnimation(Animation)
game.ReplicatedStorage.BikeAni.OnClientEvent:Connect(function()
AnimationTrack:Play()
end)
In the post above yours I used that in the local script and I got no errors but it did not do anything. I heard you needed to make the animator with Instance.new but I wasn’t sure. Do you know anything about that?
Then I assume it’s an issue with your script. Try this
elseif seat.Occupant.Name == Owner then
local humanoid = seat.Occupant
Driving = true
local Animator = Humanoid:FindFirstChildOfClass("Animator")
local Ani = Animator:LoadAnimation(script.Animation)
Ani:Play()
print('playing')
end