Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why doesn't this Gamepass script work?

Asked by 8 years ago
01local passId = 396490188
02 
03function isAuthenticated(player)
04    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId)
05end
06 
07game.Players.PlayerAdded:connect(function(plr)
08    if isAuthenticated(plr) then
09        print(plr.Name .. " has bought the game pass with id " .. passId)
10    end
11 
12function ontouch()
13    game:GetService("TeleportService").CustomizedTeleportUI = true
14local teleportService = game:GetService("TeleportService")
15local otherPlaceId = 215389447
View all 27 lines...

Thanks for answering! The goal of the script is to see if you have the game pass and if you do teleport you to another part of the universe. I tested the script out ingame and when I touched the part that was suppose to do that It wasn't doing it and I can't spot anything wrong with this script so I came to you guys for help, again thanks! :)

1 answer

Log in to vote
0
Answered by 8 years ago

You were missing a lot.

The below script should teleport the player when they touch a brick and if they have the gamepass.

01-- script in part in workspace
02local passId = 396490188
03local teleportService = game:GetService("TeleportService")
04local otherPlaceId = 215389447
05--^ variables
06 
07 
08function isAuthenticated(player) --gets activated later
09    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId)--checks for player gamepass
10end
11 
12script.Parent.Touched:connect(function(part) -- tocuhed event
13    if not part.Parent:FindFirstChild("Humanoid") then return end
14    local plr = game.Players:GetPlayerFromCharacter(part.Parent)-- get player
15    if not plr then return end
View all 21 lines...
The above script will teleport the player if they have the gamepass.

Here's some links to help in the future,

Teleport Service Guide

gamepass service

I hope I helped!

Good Luck!

Ad

Answer this question