GUI Rank-filtering Script Not Working

Hey everyone! :wave:

I’m currently trying to script a teleport button where if you’re a “Customer” in a group it’ll teleport you, but if you’re a Guest or Trainee+ it’ll make a GUI pop up saying you’re unable to get a job.

The issue is that the script isn’t working, and no errors are coming through the Output. Would anyone know a fix for this?

Script:

local button = script.Parent
local TeleportService = game:GetService("TeleportService")
local player = game.Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local JoinGroup = PlayerGui:WaitForChild("JoinGroup")
local Frame = JoinGroup:WaitForChild("Frame")
local Unable = PlayerGui:WaitForChild("Unable")
local UnableFrame = JoinGroup:WaitForChild("Frame")
local groupId = 7331168
local gameId = 6106602627

button.MouseButton1Click:Connect(function()
	if player:GetRankInGroup(groupId) == 1 then
		TeleportService:Teleport(gameId)
	else
		if player:GetRankInGroup(groupId) == 0 then
			Frame:TweenPosition(UDim2.new(0.385, 0,0.537, 0), "Out", "Back")
			wait(3)
			Frame:TweenPosition(UDim2.new(0.385, 0,1, 50), "Out", "Back")
		else
			if player:GetRankInGroup(groupId) >= 2 then
				UnableFrame:TweenPosition(UDim2.new(0.385, 0,0.537, 0), "Out", "Back")
				wait(3)
				UnableFrame:TweenPosition(UDim2.new(0.385, 0,1, 50), "Out", "Back")
			end
		end
	end
end)

Thank you in advance! :heart:

Make sure to publish it.

Studio limitation

This service does not work during playtesting in Roblox Studio — To test aspects of your game using it, you must publish the game and play it in the Roblox application.

Also make sure to turn on Third Party Teleports as well in the Game Settings

Thanks for the help, this assisted but the script is still not working with no errors.

Same with your solution, @JackscarIitt.

You cant teleport in studio, Also you cannot use GUI functions in a server script.

^ Check the above post ^
Can you double check that the gameId you typed in is valid? Also unrelated thing, but:

Why not do just elseif? It’ll organize your script a bit more & end statements

1 Like

I was about to mention this. I would suggest changing to that format to prevent logic errors.

Mhm, I’ve published the game and the script still doesn’t work. It’s a LocalScript.

I’ve tried that, it still doesn’t work, unfortunately.

If there is no Error, you most likely have a logic error. Check your conditionals to fix the problem. Nothing else we can do here.

Ok debugging time then if all else fails

local button = script.Parent
local TeleportService = game:GetService("TeleportService")
local player = game.Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
local JoinGroup = PlayerGui:WaitForChild("JoinGroup")
local Frame = JoinGroup:WaitForChild("Frame")
local Unable = PlayerGui:WaitForChild("Unable")
local UnableFrame = JoinGroup:WaitForChild("Frame")
local groupId = 7331168
local gameId = 6106602627

button.MouseButton1Click:Connect(function()
    print("Button pressed")
	if player:GetRankInGroup(groupId) == 1 then
        print("Customer!")
	    TeleportService:Teleport(gameId)
	elseif player:GetRankInGroup(groupId) == 0 then
        print("Guest/Trainee+!")
	    Frame:TweenPosition(UDim2.new(0.385, 0,0.537, 0), "Out", "Back")
	    wait(3)
	    Frame:TweenPosition(UDim2.new(0.385, 0,1, 50), "Out", "Back")
    elseif player:GetRankInGroup(groupId) >= 2 then
        print("Insert a Better Title Name here!")
	    UnableFrame:TweenPosition(UDim2.new(0.385, 0,0.537, 0), "Out", "Back")
	    wait(3)
	    UnableFrame:TweenPosition(UDim2.new(0.385, 0,1, 50), "Out", "Back")
    end
end)

I would have suggested letting OP figure out the problem before you give the answer. If she figures it out manually she will be less likely to run into a similar error in the future. I would come back later @rom8nn and try and fix the problem manually, if you still cannot fix it after an hour or 2 come back to this thread and post a reply.

All I really just did was implement print() statement & fixed the elseifs, that’s all

But yeah @rom8nn try & figure out where the issue may lie, after a while do make sure to reply back to us

I’ve managed to figure this out myself, it was a dumb mistake of mine.

This GUI was a SurfaceGui parented to a Part under Workspace. I needed to put the SurfaceGui in StarterGui and Adornee it to the Part for it to work.

2 Likes