So I am trying to help make a game for my friend [Jojo], but my animation seems to not work, I do not know why! It is R6 and so are the characters.
So I do not have any video evidence of this but here is the script, all I need to know is why it is nil or how to fix it. Some Improvement advice is fine though
So I did look on the DevForum but just… please help I followed a DevKing tutorial, I loaded animation but it did not play, and it was always nil!
Warning: Long Script
Script
repeat wait(5)
until game:GetService("Players") and game.Players.LocalPlayer and game.Players.PlayerAdded and game.Players.LocalPlayer.CharacterAdded and game.Players.LocalPlayer.CharacterAppearanceLoaded
--// Important
local Players = game:GetService("Players") -- This is the same as game.Players
local Player = Players.LocalPlayer -- You :D
local UserInputService = game:GetService("UserInputService") -- Another Service Like Players, For Input such as a keyboard or mouse movement
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AnimationFolder = ReplicatedStorage:WaitForChild("AnimationRemoteEvents")
local ValuesF = game.Workspace:WaitForChild("Values")
local TimeStoppedValue = ValuesF:WaitForChild("TimeStopped")
local Debounce = true -- Value
--// End
--[[ Fill Out Information Below ]]
local AnimationId = "rbxassetid://7427303356" -- animation Id
local Key = Enum.KeyCode.F -- KeyCode :D
-- End
--[[ Specifically For This Animation Only ]]
local LoadAnimation
local Anim
local TimeStopLength = 10
local UnPauseEvent = AnimationFolder:WaitForChild("UnPauseTime")
local Event = AnimationFolder:WaitForChild("PauseTime")
local ClientEvent = AnimationFolder:WaitForChild("PauseTimeClientEvent")
-- End Here
Players.PlayerAdded:Connect(function(PlayerI)
local Character = Player.Character
local Animation = Instance.new("Animation")
Animation.AnimationId = AnimationId
local Humanoid = Character:WaitForChild("Humanoid")
local LoadAnimation = Humanoid:LoadAnimation(Animation)
local Animation2 = Instance.new("Animation")
Animation2.AnimationId = "rbxassetid://7456382221"
local Anim = game.Workspace:WaitForChild(Players.LocalPlayer.Name).Humanoid:LoadAnimation(Animation2)
end)
Player.Character:WaitForChild("Humanoid"):GetPropertyChangedSignal("Health"):Connect(function()
if Player.Character:WaitForChild("Humanoid").Health <= 0 then
wait(game.Players.RespawnTime + 1)
local Character = Player.Character
local Animation = Instance.new("Animation")
Animation.AnimationId = AnimationId
local Humanoid = Character:WaitForChild("Humanoid")
local LoadAnimation = Humanoid:LoadAnimation(Animation)
local Animation2 = Instance.new("Animation")
Animation2.AnimationId = "rbxassetid://7456382221"
local Anim = game.Workspace:WaitForChild(Players.LocalPlayer.Name).Humanoid:LoadAnimation(Animation2)
end
end)
UserInputService.InputBegan:Connect(function(Input)
if LoadAnimation ~= nil and LoadAnimation == true then
if Input.KeyCode == Key and Debounce == true then
if not TimeStoppedValue.Value then
Event:FireServer()-- Remove this line of code if the animation that is playing is not TimeStop
ClientEvent:FireServer(true,Player.Name)
Debounce = false
LoadAnimation:Play()
local CoroutineTimeStopDestroy = coroutine.create(function()
wait(TimeStopLength)
UnPauseEvent:FireServer()
end)
coroutine.resume(CoroutineTimeStopDestroy) -- Remove if not TimeStopAnim
ClientEvent:FireServer(false,Player.Name)
wait(1)
LoadAnimation:Stop()
Debounce = true
end
end
end
end)
local LocalPlayer = Players.LocalPlayer
game.Workspace:WaitForChild(LocalPlayer.Name):WaitForChild("Humanoid").Changed:Connect(function()
if Anim ~= nil then
print("Animation exists :)")
if game.Workspace:WaitForChild(LocalPlayer.Name).Humanoid.Running then
if not Anim.IsPlaying then
LoadAnimation:Stop()
Anim:Play()
end
else
if Anim ~= nil then
if Anim.IsPlaying then
Anim:Stop()
end
end
end
else
warn("Animation Is nil :[")
end
end)
I hope this isn’t too complicated
Thank you, Sincerely- oscoolerreborn