I need help with an error in my script

Hello! My name is Frosty and recently I’ve been working on my game and I’m trying to add a burger system when you can make burgers. I’m stuck on a script that I need help on. The script is:

local Meat = game.Workspace.Oven.Meat
local SizzleSound = Meat.Parent.Sizzling
local plr = game.Workspace.StepOnButtons.OvenOpen1.PersonUsingOven.Value

script.Parent.MouseButton1Click:Connect(function()
if game.Workspace[plr].RawMeat then
Meat.Transparency = 1
wait(0.1)
SizzleSound.Script.Disabled = false
else
script.Parent.TextButton.Text = “Please hold the meat out”
script.Parent.Parent.Visible = false
wait(3)
script.Parent.TextButton.Text = “Cook Patty”
script.Parent.Parent.Visible = true
end
end)

My error I get is: [22:52:23.288 - is not a valid member of Workspace]

Basically PersonUsingOven is a string-value and I have a script set up for it to make the local players username go in there so it can access the players tools when they hold it out.

If I’m messing any other important details to help let me know.

Are you sure PersonUsingOven.Value is not nil sometimes?

1 Like

Yes, I’ve even tested it and seen my player name go into that string value.

On the client or on the server?

1 Like

I did it with the client and not the server.

Since the script that cooks the meat is on the server, and you assign the string’s value on the client, so it will return nil when you do game.Workspace[plr]. Maybe fire a RemoteEvent to the server to assign the value?

Okay, I’ll try. Thanks for helping me! :smiley:

I’d change
local plr = game.Workspace.StepOnButtons.OvenOpen1.PersonUsingOven.Value
to
local plr = game.Workspace.StepOnButtons.OvenOpen1.PersonUsingOven
and then in if game.Workspace[plr].RawMeat then do if game.Workspace[plr.Value].RawMeat then
since by making it so plr is the .Value, the plr value would stay the same through all the execution, and by making it so plr is the object and what we check if the value of the object, we’re checking the value it has at that moment.

Please use ``` on your code. ___________________________

2 Likes

Does :WaitForChild fix the issue? For instance, local meat = game.Workspace:WaitForChild("Oven")?

Sadly not. I keep getting the same error.

Still it gives me the same error.

Can you say which line is causing the error?

I looked at the error and it says line 6.

And this is all in a localscript, correct?

Happy birthday

Thank you, and yes it’s a local scrpt.

I mean not a local script sorry.

Scripts that deal with a player’s user interface should be LocalScripts.

Also, how is the PersonUsingOven value being set?

Alrighty. I have a script so when they touch a pad it puts there name in the string value.

Can I see that script? And I assume that’s a server script?

The main issue appears to be that plr is not a member of workspace.