Hello! So I wanted to script something that teleports you to another place. For some reason it’s not working. No errors, just nothing. I did test it in a real game, not in Studio.
Script:
local player = game.Players.LocalPlayer
local TeleportService = game:GetService("TeleportService")
local SurfaceGui = script.Parent
local TextButton = SurfaceGui.TextButton
local placeId = 5160756942
local defaultText = [[Click to get teleported to the Training Center.
Note that Trainings are not getting hosted all the time.]]
local ranks = {
["Guest"] = 1;
["Trainee"] = 2;
["Barista"] = 3;
["Head Barista"] = 4;
["Supervisor"] = 5;
["Manager"] = 6;
["Chief Executive Officer"] = 7;
["Developer"] = 8;
["President"] = 9;
["Founder"] = 10;
}
TextButton.MouseClick:Connect(function()
--Teleport him to the TC
--But first check his rank
local role = player:GetRoleInGroup(6615557)
local rank = ranks[role]
if rank >= 2 then
TeleportService:Teleport(placeId, player)
else
TextButton.Text = "You have to be a Trainee or above to be able to get teleported to the Training Center."
wait(3)
TextButton.Text = defaultText
end
end)
I can see a table of ranks defined with numbers, but I don’t see where the script links those ranks to the player. You are checking the ranks against a table, but the table isn’t linked to the player so the script doesn’t know which rank to use.
I’ve tried it with a Remote Event, still not working.
Script:
--Local Script
local player = game.Players.LocalPlayer
local TeleportService = game:GetService("TeleportService")
local SurfaceGui = script.Parent
local TextButton = SurfaceGui.TextButton
local defaultText = [[Click to get teleported to the Training Center.
Note that Trainings are not getting hosted all the time.]]
local RS = game:GetService("ReplicatedStorage")
local Teleport = RS.Remotes.Teleport
local ranks = {
["Guest"] = 1;
["Trainee"] = 2;
["Barista"] = 3;
["Head Barista"] = 4;
["Supervisor"] = 5;
["Manager"] = 6;
["Chief Executive Officer"] = 7;
["Developer"] = 8;
["President"] = 9;
["Founder"] = 10;
}
TextButton.MouseClick:Connect(function()
--Teleport him to the TC
--But first check his rank
local role = player:GetRoleInGroup(6615557)
local rank = ranks[role]
if rank >= 2 then
--Fire a Remote Event
Teleport:FireServer()
else
TextButton.Text = "You have to be a Trainee or above to be able to get teleported to the Training Center."
wait(3)
TextButton.Text = defaultText
end
end)
--Server Script
local RS = game:GetService("ReplicatedStorage")
local Teleport = RS.Remotes.Teleport
local TeleportService = game:GetService("TeleportService")
local placeId = 5160756942
Teleport.OnServerEvent:Connect(function(player)
TeleportService:Teleport(placeId, player)
end)
I think I’ve figured it out. From what I know about group ranks, don’t you usually get the ranks by checking a number. For example the ‘owner’ rank = 255 in the group.
game.Players.PlayerAdded:Connect(function(Player))
if player:GetRankInGroup(group id here I think) == 255 then —— 255 is owner
print(“player is owner of the group”)
end
GetRoleInGroup returns a StringValue, for example Customer. My table checks the StringValue and replaces it with a number (1-10). I can check his rank with these numbers now.
ok, I’ve not used that method before because I’m new to scripting, try using a print statement to print the player’s role. This will help see if it’s working as it should be.
Alright, that’s weird. Looks like the event is not even getting fired.
Script:
local player = game.Players.LocalPlayer
local TeleportService = game:GetService("TeleportService")
local SurfaceGui = script.Parent
local TextButton = SurfaceGui.TextButton
local TeleportService = game:GetService("TeleportService")
local defaultText = [[Click to get teleported to the Training Center.
Note that Trainings are not getting hosted all the time.]]
local ranks = {
["Guest"] = 1;
["Trainee"] = 2;
["Barista"] = 3;
["Head Barista"] = 4;
["Supervisor"] = 5;
["Manager"] = 6;
["Chief Executive Officer"] = 7;
["Developer"] = 8;
["President"] = 9;
["Founder"] = 10;
}
TextButton.MouseButton1Click:Connect(function()
print("Click")
--Teleport him to the TC
--But first check his rank
local role = player:GetRoleInGroup(6615557)
local rank = ranks[role]
print(rank)
if rank >= 2 then
print("Yes")
--Fire a Remote Event
TeleportService:Teleport(5160756942)
else
print("Else")
TextButton.Text = "You have to be a Trainee or above to be able to get teleported to the Training Center."
wait(3)
TextButton.Text = defaultText
end
end)