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?