I don't know why this doesn't work on Roblox. However, it works on studio just fine, so I am not sure what I did. I have two scripts that both work together to make a Group/Rank only teleporting GUI. Both are children under a TextButton in a ScreenGui in StarterGui.
The first script is to verify if the player is able to see/select the Teleporting GUI. Otherwise the GUI stays invisible.
local Player = game.Players.LocalPlayer if Player:IsInGroup(1122694) and Player:GetRankInGroup(1122694) >= 9 then script.Parent.Visible = true script.Parent.Selectable = true end
And the second script teleports the player.
pth = script.Parent.Parent.Parent.Parent.Character function Click() pth.Humanoid.Jump = true wait(.3) pth.Torso.CFrame = CFrame.new(-243.919, 17.021, -419.53) pth.Humanoid.Jump = false end script.Parent.MouseButton1Down:connect(Click)
I also have other ScreenGui buttons that teleport easily, but the difference between that and this one is the requirement of being in a group and in a specific rank.
You could potentially have two problems with these scripts. I'll go through them both, and let you know how to fix them.
Your first problem (possibly) is that your not using LocalScripts. Make sure both of these are LocalScripts so that you're able to access GUI functions, and LocalPlayer
properly.
Your second problem I believe is that you're not allowing the game to load in the character before attempting to index it. In studio, the game is allowed time for your character to load in before the scripts are fired, but in servers, this is not the case. You simply need to put a loop before indexing the character, and make it wait for it to load in. We'll do that like so:
repeat wait() until script.Parent.Parent.Parent.Parent.Character --Loops until character is found pth = script.Parent.Parent.Parent.Parent.Character function Click() pth.Humanoid.Jump = true wait(.3) pth.Torso.CFrame = CFrame.new(-243.919, 17.021, -419.53) pth.Humanoid.Jump = false end script.Parent.MouseButton1Down:connect(Click)
So now I believe both of these scripts should work correctly! If you have any further problems/questions, please leave a comment below, and I'll see what I can do. Anyways, hope this helped :P