Not valid member

i have a part that in my local script, it exists but when referenced later it throws error not valid member of

local car = script:WaitForChild("Car").Value

for i,v in pairs(car:GetChildren()) do

	repeat wait() until v

end


local stats = car:WaitForChild("Configurations")
local Raycast = require(car.CarScript.RaycastModule)

local rayDistance = car.RayDistance
local BaseSpeed = car.Parent.Stats.BaseSpeed.Value
local hit, position, normal
local chassis = car:WaitForChild("Chassis")

while game:GetService("RunService").Heartbeat:Wait() do

    -ERROR-
	hit, position, normal = Raycast.new(car.Chassis.Position, car.Chassis.Position.CFrame:vectorToWorldSpace(Vector3.new(0, -3.5, 0)))
    -ERROR-

end

the while loops runs which implies that the line in which the chassis wait to appear, it runs and chassis does exist but when later referenced it throws the error, it seems to bug for me idk whatelse do

EXTRA: while writing this, i found that if i do

local chassis = car:WaitForChild("Chassis")
	hit, position, normal = Raycast.new(chassis.Position, chassis.Position.CFrame:vectorToWorldSpace(Vector3.new(0, -3.5, 0)))

it works but i dont think i can do this with all child car

could you tell us the whole error you are getting?

2 Likes

well i think actually thats not the problem, the thing is that in my racing game sometimes when being teleported, u cant move when game starts, and this indicates by the speed bar
image

if the speed bar is there , that means u can move the car, but if not, u cant, and u are sitted on any cases
i dont get any errors on local script that manages car speed and stuff, on the server script neither

1 Like

Check that it’s not anchored and that everything is welded correctly together. It’s possible that a crucial part is falling through the ground and is being destroyed by void.

2 Likes