You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
a grab system to grab players
What is the issue? Include screenshots / videos if possible!
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i tried using waitforchild and findfirstchild
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:FindFirstChildOfClass("Humanoid")
local anim = script.Parent.Grabbing
local animationgrabbing = hum:LoadAnimation(anim)
local tool = script.Parent
local debounce = false
local cd = 7
tool.Activated:Connect(function()
if debounce == false then
debounce = true
animationgrabbing:Play()
wait(cd)
debounce = false
end
end)
The error is saying you tried to index the object ‘nil’ with the method or instance ‘Animator’.
The game thinks that the player’s Humanoid is nil, since you tried to call Animator.
With that being said, are you sure that the code you provided is exactly what you’re running? The error screenshot and the code snipped you provided seem to not be the same.
To summarize, ensure that your code is actually getting the player’s humanoid or any instance that you are trying to use.
I believe the script is running the second the character is added (If this is in StarterCharacterScripts) So the humanoid hasn’t been created yet, You said you used WaitForChild() on the hum variable already (like char:WaitForChild(“Humanoid”)) So maybe try setting the “AnimationGrabbing” variable inside the Activated function.
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local anim = script.Parent.Grabbing
local tool = script.Parent
local debounce = false
local cd = 7
tool.Activated:Connect(function()
if debounce == false then
debounce = true
local animationgrabbing = hum:LoadAnimation(anim)
animationgrabbing:Play()
wait(cd)
debounce = false
end
end)