Scripting Support Needed

Why won’t this work? Gives no error and also doesn’t print clicked.

local player = game.Players.LocalPlayer
local x2Stone = game.StarterGui.GamepassButton.GamepassFrame.ScrollingFrame.x2Stone
local marketPlaceService = game:GetService("MarketplaceService")

local gamePassId = 111451515

local exitButton = game.StarterGui.GamepassButton.GamepassFrame.ExitButton
local gamePassButton = game.StarterGui.GamepassButton.Frame.TextButton

gamePassButton.MouseButton1Click:Connect(function()
	print("Clicked")
	if game.StarterGui.GamepassButton.GamepassFrame.Visible == true then
		game.StarterGui.GamepassButton.GamepassFrame.Visible = false
	else
		game.StarterGui.GamepassButton.GamepassFrame.Visible = true
	end
end)

Where is the script located in the explorer.
Because local scripts don’t work inside workspace

It’s located in starterplayerscripts

Don’t use StarterGui, use PlayerGui

I have updated the script but still deosn’t work?


local player = game.Players.LocalPlayer
local marketPlaceService = game:GetService("MarketplaceService")

local gamePassId = 111451515

local exitButton = player:WaitForChild("PlayerGui"):WaitForChild("GamepassFrame"):WaitForChild("ExitButton")
local gamePassButton = player:WaitForChild("PlayerGui"):WaitForChild("GamepassButton"):WaitForChild("Frame"):WaitForChild("TextButton")
local GamepassGui = player:WaitForChild("PlayerGui"):WaitForChild("GamepassGui")

gamePassButton.MouseButton1Click:Connect(function()
	if GamepassGui.Enabled == true then
		GamepassGui.Enabled = false
	else
		GamepassGui.Enabled = true
	end
end)

Why do u use Enabled instead of visible and try

local player = game.Players.LocalPlayer
local x2Stone = player.PlayerGui:WaitForChild("GamepassButton").GamepassFrame.ScrollingFrame.x2Stone
local marketPlaceService = game:GetService("MarketplaceService")

local gamePassId = 111451515

local gamepassButton = player.PlayerGui:WaitForChild("GamepassButton")
local exitButton = gamepassButton.GamepassFrame.ExitButton
local gamePassButton = gamepassButton.Frame.TextButton

gamePassButton.Activated:Connect(function()
	print("Clicked")
        gamepassButton.GamepassFrame.Visible = not gamepassButton.GamepassFrame.Visible
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.