Top bar plus for code

i have a skip stage button code in starter gui and I’m trying to use topbarplus to do it, what I tried:

local Icon = require(game:GetService("ReplicatedStorage").Icon)
local icon = Icon.new()
:setLabel("Skip")
:setTip("Click to Buy Skip!")
icon.MouseButton1Click:Connect(function()
	
	local Checkpoints = workspace:WaitForChild("Checkpoints")

	local Players = game:GetService("Players")
	local player = Players.LocalPlayer
	local StageLeaderstat = player:WaitForChild("leaderstats"):WaitForChild("Level")

	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local SkipStage = ReplicatedStorage:WaitForChild("SkipStage")


			if #Checkpoints:GetChildren() ~= StageLeaderstat.Value then
		local Response = SkipStage:InvokeServer()
		end
	end)


local player = game:GetService("Players").LocalPlayer
local playerGui = player.PlayerGui

the gui script

local TextButton = script.Parent
local Checkpoints = workspace:WaitForChild("Checkpoints")

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local StageLeaderstat = player:WaitForChild("leaderstats"):WaitForChild(	"Level")

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SkipStage = ReplicatedStorage:WaitForChild("SkipStage")

TextButton.MouseButton1Click:Connect(function()
	if TextButton.Text == "Skip Level" then
		if #Checkpoints:GetChildren() ~= StageLeaderstat.Value then
			TextButton.Text = "Buying..."
			local Response = SkipStage:InvokeServer()
			TextButton.Text = Response
		else
			TextButton.Text = "your are at the last stage lol"
		end
		wait(2)
		TextButton.Text = "Skip Level"
	end
end)
1 Like

u cant use mousebutton1click while using the topbarplus
instead use this :

function skipstage()
--skip stage code here
end
--button is selected
icon.selected:Connect(function()
skipstage()
end)
--button is deselected
icon.deselected:Connect(function()
skipstage()
end)

i hope this will help

finally! i have been waiting for a response for two years!

1 Like