not a valid member roblox function code example

Example: not a valid member roblox

local Touch = workspace:WaitForChild("ItemShopTouch"):WaitForChild("Touch")

-- since this is a local script, we can get player easily
-- with this
local player = game.Players.LocalPlayer

-- GUI's in StarterGui will cloned into player > PlayerGui
-- which is the exact place of UI
local JOJO Shop = player.PlayerGui:WaitForChild("JOJO Shop")

-- used to make the script dont run constantly
local debounce = false

-- in game, the script will be inside item
local item = script.Parent

-- whenever the `Touch` Part were Touched, this code runs
Touch.Touched:Connect(function(hit)

	-- check if hit (part) parent is a item
	if hit.Parent == item then

		-- check if debounce variable is false
		if not debounce then
			-- setting debounce to true will make the code
			-- wont run again until it sets into false again
			debounce = true

			-- now the actual code

			-- enable (toggle visibility) of the gui
			-- to true (makes the gui shown in player screen
			JOJO Shop.Enabled = true

			----------------------

			-- wait 2 seconds then set debounce to false
			-- or basically enables the code again after
			-- 2 seconds
			wait(2)
			debounce = false

		end

	end

end)

Tags:

Lua Example