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

Cant find the location of the tool, can anyone help?

Ok, so basically I found the backpack in this script but it turns out I cant find the tool inside of the backpack.

Error: Tray is not a valid member of Backpack"

I did put it in starter pack so it'll get transferred to the player's backpack, however it said that the tool isn't a member of backpack, when it is.

I don't understand what is wrong, can anyone give feedback/help?

Code:

	local ProximityPromt = script.Parent.ProximityPrompt
	--- Pizza Models
	local Pizza1 = game.Workspace.Pizza1
	local Pizza2 = game.Workspace.Pizza2
	local Pizza3 = game.Workspace.Pizza3
local Pizza4 = game.Workspace.Pizza4

game.Players.PlayerAdded:connect(function(player)
	local Backpack = player.Backpack
	local Tray = Backpack.Tray
end)
 
ProximityPromt.Triggered:Connect(function()
	ProximityPromt.ActionText = "Cook"
	    if ProximityPromt.ActionText == "Cook" then
			        Pizza1.Transparency = 0
			        ProximityPromt.Enabled = false
		wait(15)
		ProximityPromt.Enabled = true
		ProximityPromt.ActionText = "Pick Up"
		ProximityPromt.Triggered:Connect(function()
			Pizza1.Transparency = 1
			wait(5)
			ProximityPromt.ActionText = "Cooldown..."	
		end)
				     
			 
	end
end)

1 answer

✓ Accepted answer

The 'event' ran before the 'Tray' can load in. I suggest using ':WaitForChild()' to make up for it. By the way, I'm kinda rep-hungry... Anyways. Happy scripting!

1 comment

0

Oh ok, Thanks!

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