Im trying to make a grab script but i see a error thats not really going with what i made

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    a grab system to grab players
  2. What is the issue? Include screenshots / videos if possible!
    slamscript
  3. 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)
1 Like

im pretty sure hum:LoadAnimation() is deprecated now. Try using hum.Animator:LoadAnimation(anim) instead

ahi

tried it and it didnt work.

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.

2 Likes

Yes im sure of what im running

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.

1 Like

Try this:

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)
1 Like

Thanks bro this help alot it was the solution

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.