I am getting the error: Workspace.SteamG0D.ControlScript:14: attempt to index upvalue 'V' (a nil value)
What I am trying to do is have a script give assign it's parent to the value of an ObjectValue, which does work, and then once that happens, another script (a local script inside the player character) applies actions to the parts inside the ObjectValue's referenced object.
local uis = game:GetService("UserInputService")
local player = script.Parent
local V = player.Obj.Value --player.Obj is the ObjectValue
local light = false
uis.InputBegan:Connect(function(Input, IsTyping)
if Input.KeyCode == Enum.KeyCode.Y and not IsTyping then
if light then
print("Y has been pressed OFF")
V.Base.BodyForce.Force.Y=0
else
print("Y has been pressed ON")
V.Base.BodyForce.Force.Y=workspace.Gravity
end
end
end)

10 comments
You're setting V to the VALUE of your ObjectValue, not setting it as a pointer to whatever the value happens to be at the current time. If you set it at the start and it's nil, it will be nil forever.
@fredfishy is there any way to set an object as a pointer to a value then?
You can't, and you don't need to. I can write up an answer if you want, so I can explain the difference between a pointer and a value. If you're meaning a pointer to the property .
I understand the difference, I just wasn't sure if ObjectValues acted as a pointer or not, hadn't ever used them before. Now the reason why I do need to store a pointer to an object is so that I can have a player script apply actions to parts in an object that won't be known until my player sits in a seat.
Just make a direct access to the Value property of the ObjectValue.
I don't understand what you mean by that, I thought that's what i was doing.
It seems you got confused there, I'm trying to store a pointer to an object, not a pointer to a value, a pointer to a value wouldn't make sense.
I mean, plr.Obj.Value
Whenever you need to change the value or just need to fetch it, make a direct access
well the problem with that is that it returns a nil value eventhough it has clearly been set to something, I can set it to something (I literally hunted it down in the workspace and it appeared to have the correct value set to it), but it still gives an error message saying it is a nil value