Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does this script not index "veh"?

Asked by 8 years ago
veh = game.Workspace:FindFirstChild(script.Parent.Parent.CarName.Value, true)
airhorn = veh.lightbar1.middle.Manual
function Click(mouse)
airhorn:Play()
veh.lightbar1.middle.Yelp:Stop()
veh.lightbar1.middle.Wail:Stop()
end
function Unclick(mouse)
airhorn:Stop()
end
script.Parent.MouseButton1Down:connect(Click)
script.Parent.MouseButton1Up:connect(Unclick)

I get error cannot index veh. I have a script giving the cars a unique random name and the CarName value matches it (I checked and that works).

1
Please put your code in a code block (the blue "Lua" button at the top of the question box) darkelementallord 686 — 8y
0
I have put it in the code block now. nestenes 0 — 8y
0
Is `veh` nil? What's the error? Are you sure this script is running *after* the model exists, is named, and after `CarName.Value` is set? Have you `print()`d anything to verify that? BlueTaslem 18071 — 8y
0
I figured it out, the Value of the object was being changed more than once. nestenes 0 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Try doing :WaitForChild instead of :FindFirstChild, other than that, I have no idea. XD

Ad

Answer this question