Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does this script not index "veh"?

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).

4 comments

1

Please put your code in a code block (the blue "Lua" button at the top of the question box)

0

I have put it in the code block now.

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?

0

I figured it out, the Value of the object was being changed more than once.

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.