Hello, Im currently making a fighting game based on JJBA (i know its the 2983213 jjba game), but ive got a problem on a script, or an animation i guess.
What ive been trying to achieve is when this event is fired (Client to Server) an animation plays (the idle animation for the stand), but it keeps giving me an error. (the stand doesnt have humanoid, it does have AnimControl)
This is the code im using:
game.ReplicatedStorage.Release.OnServerEvent:Connect(function(plr, standname)
local char = plr.Character
local stand = char:WaitForChild(standname)
local humanoidroot = char:WaitForChild("HumanoidRootPart")
local Anim = stand:FindFirstChild("AnimationController")
local idle = Anim:LoadAnimation(workspace.Animations.Idle)
idle:Play()
end)
And this is the error it gives:
ServerScriptService.Release:6: attempt to index nil with 'LoadAnimation
Support is appreciated.
Also im not really a good scripter so any info about how to improve my scripting is very much appreciated!
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.Release.OnServerEvent:Connect(function(Player, StandName)
local Character = Player.Character
local Stand = Character:WaitForChild(StandName)
local AnimationController = Stand:FindFirstChildOfClass("AnimationController")
local IdleAnimation = AnimationController:LoadAnimation(workspace.Animation.Idle)
IdleAnimation:Play()
end)
Client:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.Release:FireServer("StandNameHere")
What I’m guessing is you did
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
ReplicatedStorage.Release:FireServer(Players.LocalPlayer, "StandNameHere")
which wouldn’t work because the player is already defined when you fire a remote and so it would consider your player as the inputted standname
Just a hunch, but try switching stand:FindFirstChild("AnimationController") to WaitForChild like I did below, it’s possible its not getting it. If in output it says Infinite Wait or something along those lines then you know that what your trying to get isnt actually there. Same goes for the Idle animation which I also added a WaitForChild. If none of these display anything in output then something is wrong with the remote.
game.ReplicatedStorage.Release.OnServerEvent:Connect(function(plr, standname)
local char = plr.Character
local stand = char:WaitForChild(standname)
local humanoidroot = char:WaitForChild("HumanoidRootPart")
local Anim = stand:WaitForChild("AnimationController")
local idle = Anim:LoadAnimation(workspace:WaitForChild("Animations"):WaitForChild("Idle"))
idle:Play()
end)
Oh I think you created the stand on the client side! If that’s the case then you need to create it on the serverside instead or handle animations on the client. The server cannot see what is being made on the client without the use of remote events.