Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

GUI Rank-Only Teleporter not working?

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.

2 comments

0

Naturally when something works in studio but not in-game, you have to presume that it's something to do with serverscripts trying to access client-only stuff (saying as studio always runs on the client). Have you got FilteringEnabled working?

0

I am starting to learn how to script better, but I am not very familiar with FilteringEnabled. I will look into it though. Thanks!

1 answer

✓ Accepted answer

You could potentially have two problems with these scripts. I'll go through them both, and let you know how to fix them.


###Problem #1 - Scripts 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.


###Problem #2 - Character (Second Script) 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

####-Dyler3

This discussion is preserved as it was. New answers, comments, and votes are closed.