Basically, 'attempt to index upvalue 'veh' (a nil value)' keeps popping up whenever I try to run this script, and I have not come across this problem before, so I'm quite confused on how to fix it. It's quite a simple script and uses value's. The script is inside a TextButton, along with the value which holds the name of the model I want the script to access. Here's the script:
local veh = game.Workspace:FindFirstChild(script.Parent.CarName.Value)
script.Parent.MouseButton1Click:connect(function()
script.Parent.TextColor3 = Color3.new(170, 0, 0)
script.Parent.TextTransparency = 0.5
veh.Model.p1.Transparency = 0
veh.Model.p2.Transparency = 0
veh.Model.p1.Anchored = true
veh.Model.p2.Anchored = true
end)
Any help fixing this is appreciated.

6 comments
And what is script.Parent.CarName.Value?
There is a value inside of the TextButton which holds the name of the model I'd like to access using the script when the TextButton is clicked. (Holds the car name)
try using WaitForChild instead of FindFirstChild
I can't otherwise it wouldn't look for the model in Workspace?
Waiting for something with waitForChild functions the same as a FindFirstChild, exept it will not run the rest of the script until that object/value it's waiting for has loaded.
Tried it. Still not interested in working.