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

Console system doesn't work and gives no errors?

I want to make a system that checks whether the player has the specific item, and if the player does, then the console would "work". However, the code didn't give me errors and it doesn't work.

Also, I don't really know how to exactly make a system that only destroys the tool if the player pressed the proximity prompt again. For now, it instantly destroys it if the player picks it up after pressing it. (Edit: turns out the textlabel also doesn't work for some reason)

local proxPrompt = script.Parent.ProximityPrompt

proxPrompt.Triggered:Connect(function(touched)
	local backpack = touched:FindFirstChild("Backpack")
	local backpackGame = backpack:WaitForChild("game")
	if backpackGame then
		backpackGame:Destroy()
	elseif backpackGame == nil then
		local cantInsertItemGui = game.StarterGui.CantInsertItemGui
		local textLabel = cantInsertItemGui.TextLabel
		textLabel.Visible = true
		textLabel.Text = "you need a game to play on the console"
	end
end)

7 comments

0

im not sure why your using WaitForChild instead of FindFirstChild but try putting an amount of seconds to wait for as a second parameter in WaitForChild because i think its infinitely yielding

0

The FindFirstChild fix worked for the everything before "elseif", thanks. (I didn't point out the textlabel was not working at first.)

0

oof I hate it when there is not a error.

0

is this local or not local?

0

xxaxxaz is once again wrong in his answer. the reason this doesnt work is because game.StarterGui isn't the playergui, StarterGui clones and goes in each player --> playergui. This explains no errors.

0

ah okay thanks, ill try it soon and hope it works

0

thanks everyone, the tips you gave me really helped with the script.

1 answer

this needs two scripts, one local and one not local

not local script:

local proxPrompt = script.Parent.ProximityPrompt

proxPrompt.Triggered:Connect(function(touched)
  	  local backpack = touched:FindFirstChild("Backpack")
 	   local backpackGame = backpack:WaitForChild("game")
  	  if backpackGame then
        	backpackGame:Destroy()
	end
end)

local script:

local proxPrompt = script.Parent.ProximityPrompt

proxPrompt.Triggered:Connect(function(touched)
    if backpackGame == nil then
        local cantInsertItemGui = game.StarterGui.CantInsertItemGui
        local textLabel = cantInsertItemGui.TextLabel
        textLabel.Visible = true
        textLabel.Text = "you need a game to play on the console"
    end
end)

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