Local Script Gamepass Room GUI Issue

Let me explain.
This script is inside a button, which checks if the player owns the gamepass, and if they do - they will be teleported to a custom vip room. If they don’t own it, they will be teleported back away from the part which causes the gui button to appear.

The issue
If one player owns the gamepass, and successfully teleports the the room, all the other players will be teleported to a place away from the part that causes the gui to open up - this is not the gamepass room just to avoid the player from having the menu show

It is a local script, in startergui.

local part = workspace.TimeTeleport -- Name of part you want to teleport to
local plr = game.Players.LocalPlayer
local menu = script.Parent.Parent.Parent.ElevatorMain.Parent.Parent.Elevator.Parent.Parent.Elevator3

local MarketPlaceService = game:GetService("MarketplaceService")



script.Parent.MouseButton1Click:Connect(function()
	local GamepassID = 28396151
	local Player = game.Players.LocalPlayer
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, GamepassID) then
		print("Player owns gamepass.")
	
	
    local humanoidrootpart = plr.Character:FindFirstChild("HumanoidRootPart")
    
		humanoidrootpart.CFrame = CFrame.new(part.CFrame.p) + Vector3.new(0,5,0)
		script.Parent.Sound:Play()
		menu.Enabled = false
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
		game.Players.LocalPlayer.Character.Humanoid.JumpPower = 7.2
			
		else
		print("Player doesn't own gamepass")
		game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer, GamepassID)
		MarketPlaceService.PromptGamePassPurchaseFinished:Connect(function(player, GamepassID, was_purchased)
			if was_purchased == true then
				local humanoidrootpart = plr.Character:FindFirstChild("HumanoidRootPart")
				humanoidrootpart.CFrame = CFrame.new(part.CFrame.p) + Vector3.new(0,5,0)
				script.Parent.Sound:Play()
				menu.Enabled = false
				game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
				game.Players.LocalPlayer.Character.Humanoid.JumpPower = 7.2
				
			else
				local part2 = game.Workspace.TopTeleport
				local humanoidrootpart = plr.Character:FindFirstChild("HumanoidRootPart")
				humanoidrootpart.CFrame = CFrame.new(part2.CFrame.p) + Vector3.new(0,5,0)
				menu.Enabled = false
				game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
				game.Players.LocalPlayer.Character.Humanoid.JumpPower = 7.2
			end

		end)
    end
end)
2 Likes

just realised what a mess this script is lmao, havent coded in ages

2 Likes

found the issue, it was my horrible anti cheat