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

Help me with this gamepass GUI?

I made a GUI that teleports a player that has the game pass to be telported to a certain place and if he doesnt have it it wont teleport him! Either way the player is not teleported help me please!

print("teleport")
brick = workspace["Tele3"]
player = script.Parent.Parent.Parent.Parent.Character

local passId = ########  -- Id of gamepass here!

function HasGamePass(Player)
	return game:GetService("GamePassService"):PlayerHasPass(player, PassId)
end



game.Players.PlayerAdded:connect(HasGamePass)
if HasGamePass(plr) then
	function tele()
player.Torso.CFrame = brick.CFrame + Vector3.new(0,4,0)
	end
else
	print ("Player Does not have game pass!")
end




script.Parent.MouseButton1Down:connect(tele)

2 answers

For one, "plr" is a bad parameter. So I suggest to use a different term. Maybe the id is incorrect.I'm not 100% sure but the 3rd line after character maybe it should say " = true".

This might work better.

--Make sure this is on the correct TextButton on StarterGui.

print("teleport")
brick = workspace.Tele3 --Make sure the brick is in the workspace, not in a model, and make sure the brick name is similar to the brick mentioned in the script.
player = script.Parent.Parent.Parent.Parent.Character

local passId = "PUT GAMEPASS ID HERE"  -- Id of gamepass here!

game:GetService("GamePassService"):PlayerHasPass(player, passId):connect(HasGamePass)

game.Players.PlayerAdded:connect(HasGamePass)
if HasGamePass(player) then
    function tele()
player.Torso.CFrame = brick.CFrame + Vector3.new(0,4,0)
    end
else
    print ("Player Does not have game pass!")
end


script.Parent.MouseButton1Down:connect(tele)

NOTE : This is untested. It may or may not work. Hope this helped! If it worked, please accept my answer!

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