The roblox refuses the existence of the hitbox

i’v been following this tutorial (https://www.youtube.com/watch?v=y4fpzKz-hiY&t=1185s)

at the first testing i encountered the problem attempt to index nil with cframe in the 30th row
capture1

but the nil is not really a nil couse its exists in the workplace

i looked on the internet but the other problems not similar to mine

local rs = game:GetService("ReplicatedStorage")
local animations = rs.grabmove.Animations

local Handler = {}

Handler.playerdebounce = {}
Handler.confirmedtarget = {}
Handler.cooldown = 1

function Handler:PlayAnimations(humanoid: Humanoid, TypeOfAnim: string)
	local currentanimation
	
	if TypeOfAnim == "user" then
		currentanimation = humanoid.Animator:LoadAnimation(animations.gAnimate1)
	elseif TypeOfAnim == "target" then
		currentanimation = humanoid.Animator:LoadAnimation(animations.gAnimate2)
		
	end
	return(currentanimation)
end

function Handler:Spawnhitbox(player, root)
	
	local Folder = Instance.new("Folder")
	Folder.Name = "GrabMove"
	Folder.Parent = workspace
	
	local Hitbox = rs.grabmove.Hitbox:Clone()
	Hitbox.Parent = Folder
	Hitbox.CFrame = root.CFrame * CFrame.new(0,0, -2,5)

	
	local weld = Instance.new("Weld")
	weld.Part0 = Hitbox
	weld.Part1 = root
	weld.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
	weld.Parent = weld.Part0
	
	
end

return Handler

it must be a problem with the arguments you are passing in the Handler:Spawnhitbox() function. can you show me the code where you use that function?

handler.Spawnhitbox(player,rootPart)

that’s not what i meant, sorry if i was being vague.
can you tell me where exactly you use this function in a different script? i need to know what you passed as the rootPart variable.

i dont know if it matters but before i tried to fix myself there wasnt a player variable i added that one

i hope you wanted this

local rootPart = character:FindFirstChild(“HumanoidRootPart”)

its probably because it can’t find the HumanoidRootPart. try switching it to a :WaitForChild() function instead.

you mean this way ?

local rootPart = character:WaitForChild(“HumanoidRootPart”)

if yes its doesnt work
if no i dont quite get it

is there any new messages in the output? something like Infinite yield possible or anything?

no

just for my failed money script but i disabled it

after redoing it the end of this was with a : instead of a .

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