Help with Tweening player

I am trying to tween a player, but my script is returning nil with the hrp. Here’s my script:

local prompt = script.Parent.ProximityPrompt

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local fireRepel = ReplicatedStorage.FireRepel

local endCFrame = game.Workspace.EndOfRope.Top.CFrame
local goal = {}
goal.Position = endCFrame

local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
	3,
	Enum.EasingStyle.Quart,
	Enum.EasingDirection.In,
	0,
	false
)

prompt.Triggered:Connect(function(plr)
	fireRepel:FireClient(plr)
	local humanoid = plr:FindFirstChild("Humanoid")
	local hrp = humanoid:WaitForChild("HumanoidRootPart")
	
	local repelTween = TweenService:Create(hrp, tweenInfo, goal)
	
	repelTween:Play()
end)

The error says Workspace.StartOfRope.Top.Repel:22: attempt to index nil with 'WaitForChild'.
How do I fix this?

local hrp = humanoid:WaitForChild("HumanoidRootPart")

You are searching for the HRP in the humanoid but you need to search for the HRP in the character
because the HRP is inside the character

correct way

local hrp = plr.CharacterAdded:Wait():WaitForChild("HumanoidRootPart")
1 Like