Hello!
I try to make a gravity script that enables gravity when you reach a certain height.
I have a part in the air that enables this function when a player touches this.
However this doesn't work.
I keep recieving the error:
19:21:48.959 - Workspace.Script:2: attempt to index a nil value
My script:
game.Workspace.GravityLine.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("UpperTorso"):FindFirstChild("BodyForce") then
hit.Parent:FindFirstChild("UpperTorso"):FindFirstChild("BodyForce").Force = Vector3.new(0,2000,0)
else
local bodyForce = Instance.new("BodyForce",hit.Parent:FindFirstChild("Uppertorso"))
bodyForce.Force = Vector3.new(0,2000,0)
end
end)
Thanks for helping!
Kees
