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

Getting an Object error when attempting to find ID Value in Workspace?

Asked by
E_Link 0
4 years ago

Hello,

I'm trying to find an object in the workspace by using a value. When printing the value, it prints out the value "WM830" as a string. But it's not finding the model in the workspace.

This is the code:

script.Parent.MouseButton1Click:connect(function()
    local busId = script.Parent.Parent.Parent.Car.value
    game.Workspace[busId].Body.Display.maindest.SurfaceGUI.TextLabel.text = "Woop"
end)

This is the error: Players.E_Link.PlayerGui.A-Chassis Interface.NXUI.TextButton.Script:3: bad argument #2 to '?' (string expected, got Object)

1 answer

Log in to vote
0
Answered by
Asceylos 562 Moderation Voter
4 years ago
Edited 4 years ago

Value classes have a Value property that contains the value.

Change line 2 to:

local busId = script.Parent.Parent.Parent.Car.value.Value
0
Didn't work, getting this error: E_Link 0 — 4y
0
value is not a valid member of Model E_Link 0 — 4y
0
Your "value" instance simply doesn't exist then. Asceylos 562 — 4y
0
But it does, because I've printed it.. E_Link 0 — 4y
0
Provide us with all code associated with this issue. Asceylos 562 — 4y
Ad

Answer this question