Hello Roblox developer community! I am attempting to play an animation, but it isn’t working. I am a beginner scripter, do you guys know what’s wrong with my code? Please note that I am only posting part of my code, because there is no point in posting the parts that work.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local anim = script.Parent.Fall
local animLoad = animator:LoadAnimation(anim)
animLoad:Play()
local character = player.Character if the character doesn’t exist by the time the script runs, it will nil, so change the line to local character = player.Character or player.CharacterAdded:Wait()
Is the script running? What type of script is it and where is located? If it’s a localscript, ensure it is located in a place that they can run in, PlayerGui, StarterPlayerScripts, StarterCharacterScripts, anything that is a descendant/related to a player instance
Oh, I thought it wouldn’t work because you created a variable after you used the variable in that script. I was just looking the script over and I noticed that so I thought it wouldn’t work. I understand my error now. Sorry, I’m a beginner scripter, so I didn’t notice you called the function creating the variable before you called the function using it as a parameter.
Its oke to make mistakes, its oke for the compiler to throw errors
learn from your mistakes, read the errors
It wont harm to google: ‘How to create a part in roblox with script’, ‘How to set size of part roblox’
Documentation is your boss aka. Read through the documentation, if you scrooll down you get a full example.
In general those tips work when programming (not only roblox).
Just next time, don’t ask for help if you are not willing to try solutions people provides you. It takes time to make those solutions and if you just say. YES THAT WONT WORK CAUSE I’M BETTER THEN A COMPILER you are just ego trippin. Try to run it atleast once and ask questions on things that happen when trying the provided solution.