#improve gamepass

1 messages · Page 1 of 1 (latest)

fallow badge
#
local plr = game.Players.LocalPlayer
local marketplaceservice = game:GetService("MarketplaceService")
local button = script.Parent
local gamepassid = 1407830552
button.Activated:Connect(function()
    marketplaceservice:PromptGamePassPurchase(plr , gamepassid)
end)
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success,error_msg = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if success then
        print("player already have gamepass")
    else
        error(error_msg)
    end
end)

marketplaceservice.PromptGamePassPurchaseFinished:Connect(function(plr , id , waspurch)
    if id == gamepassid and waspurch then
        print("hi")
    else
        print("play other game poor person")
    end
end)
#

i am new to gamepasses but is this script will work good ?

random willow
#

I dont know

fallow badge
hollow oyster
#

no

#

wont work

#

cuz ur checking for success

hollow oyster
#

instead of error_msg

#

smh

edgy violet
#

but improve the variable names

#

use camelCase

fallow badge
#

camelCase ?

hollow oyster
edgy violet
#

like this wasPurchase

hollow oyster
#

read it

edgy violet
#

why did u do error?

#

warn at least?

#

if u error then the script will break

hollow oyster
#

Don't do error + don't do success

fallow badge
#

so i change error with warn ?

edgy violet
fallow badge
edgy violet
#

success is correct

hollow oyster
#

no

edgy violet
#

only the error part is wrong?

hollow oyster
#

ur dumb

#

omg

#

pcall returns two things

#

if the function worked

#

and

#

the functiosn return

fallow badge
#

what should i do ?

hollow oyster
#

so if success will run

edgy violet
#

dumbass

hollow oyster
#

BRO

edgy violet
#

u need add a success

hollow oyster
#

omg

#

these s1's

#

bro

edgy violet
#

ur the dumb one

hollow oyster
#
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success,error_msg = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if success and error_msg then
        print("player already have gamepass")
    else
        warn(error_msg)
    end
end)

marketplaceservice.PromptGamePassPurchaseFinished:Connect(function(plr , id , waspurch)
    if id == gamepassid and waspurch then
        print("hi")
    else
        print("play other game poor person")
    end
end)
#

smh

edgy violet
#

or actually never mind

fallow badge
#
warn(error_msg)
``` like this ?
edgy violet
#

if not success

#

my bad chat

edgy violet
#

he means

hollow oyster
#

if success is true then error_msg will be the value returned by the userownsgamepassasync

edgy violet
#
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success,error_msg = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if not sucess then
       warn(error_msg)
    end
end)

marketplaceservice.PromptGamePassPurchaseFinished:Connect(function(plr , id , waspurch)
    if id == gamepassid and waspurch then
        print("hi")
    else
        print("play other game poor person")
    end
end)
hollow oyster
#

ill explain

edgy violet
#

my code is correct

hollow oyster
fallow badge
#

ok so now can u edit name of erro_msg and every thing wrong ?

#

bec u guys are opposite to each other and i got confused

hollow oyster
#
local function divideByFive(n: number): number
    return n / 5
end

local success, errorMessage = pcall(divideByFive, 5)  -- Results in error...

if success then
    -- Handle successful response...
    print(errorMessage) -- 1
else
    warn("Error message:", errorMessage)
end
edgy violet
#
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success,error_msg = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if success then
        ---- do something here
    end
    if not sucess then
       warn(error_msg)
    end
end)

marketplaceservice.PromptGamePassPurchaseFinished:Connect(function(plr , id , waspurch)
    if id == gamepassid and waspurch then
        print("hi")
    else
        print("play other game poor person")
    end
end)
robust quiver
hollow oyster
#

ong

#

they dont understand how pcall works

#

smh

#

these s1's need to get better bro

fallow badge
edgy violet
hollow oyster
#

do you need me to explain you how pcall works

fallow badge
robust quiver
edgy violet
fallow badge
#

@robust quiver what should i edit in script ?

hollow oyster
edgy violet
#

@robust quiver explain

hollow oyster
#

success is if the code worked on not

edgy violet
hollow oyster
#

errorMsg will be the value returned by UserOwnsGamePassAsync

edgy violet
#

pyro

hollow oyster
#

if success is true

edgy violet
#

explain to him

robust quiver
hollow oyster
fallow badge
robust quiver
fallow badge
fallow badge
#

cant*

hollow oyster
#

RIGHT

#

?!?!

robust quiver
#

yall going mad

edgy violet
#

U NEED TO PRINT SUCCESS

robust quiver
#

if op's code works then its fine idk why need to change anything?

edgy violet
#

NOT ERROR

fallow badge
#
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success,error_msg = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if success then
        print("player already have gamepass")
    else
        warn(error_msg)
    end
end)
``` this part i need to change thing ? @robust quiver
hollow oyster
#

even if the UserOwnsGamePassAsync comes out as false

#

it will still say

#

player already have gamepass

#

cuz success

#

will still be true

edgy violet
#

omg i think we are confused

#

hold on a sec

#

@fallow badge why did u name it error message

#

why not result

hollow oyster
# edgy violet omg i think we are confused

;compile

local function divideByFive(n: number): number
    return n / 5
end

local success, errorMessage = pcall(divideByFive, 5)  -- Results in error...

if success then
    -- Handle successful response...
    print(errorMessage)
else
    warn("Error message:", errorMessage)
end
rose mossBOT
#
Program Output
/opt/wandbox/lua-5.4.7/bin/lua: prog.lua:1: ')' expected near ':'

hollow oyster
#

type error

#

i used roblox's code

#

my bad

robust quiver
#

success is too many letters

hollow oyster
#

;compile

local function divideByFive(n)
    return n / 5
end

local success, errorMessage = pcall(divideByFive, 5)  -- Results in error...

if success then
    -- Handle successful response...
    print(errorMessage)
else
    warn("Error message:", errorMessage)
end
rose mossBOT
#
Program Output
1.0

hollow oyster
#

;compile

local function divideByFive(n)
    return n / 5
end

local success, errorMessage = pcall(divideByFive, "hi")  -- Results in error...

if success then
    -- Handle successful response...
    print(errorMessage)
else
    warn("Error message:", errorMessage)
end
rose mossBOT
#
edgy violet
hollow oyster
robust quiver
hollow oyster
edgy violet
#

name it result for fcksake

#

i got confused

#

kasper is right

hollow oyster
edgy violet
#

its the variable

hollow oyster
#

im showing the code

edgy violet
#

that made me confused

hollow oyster
#

check the code

#

i just copied roblox's code

edgy violet
#

yes yes i know

hollow oyster
#
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success,error_msg = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if success and error_msg then
        print("player already have gamepass")
        --PLAYER OWNS THE GAMEPASS
    elseif not success then
        warn(error_msg)
    else
        print("PLAYER DOES NOT OWN THE GAMEPASS")
    end
end)

marketplaceservice.PromptGamePassPurchaseFinished:Connect(function(plr , id , waspurch)
    if id == gamepassid and waspurch then
        print("hi")
    else
        print("play other game poor person")
    end
end)
edgy violet
#

if sucesss

#

and u print out the result

#

if not success

#

you also print out the result

fallow badge
#

my brainnnnnnnnnnnnn

edgy violet
#

fix it

robust quiver
fallow badge
edgy violet
hollow oyster
#
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success,error_msg = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if success  then
      if error_msg then
        print("Player owns gamepass")
      else
        print("Player does not own gamepass")
      end
    else
        print("UserOwnsGamepassAsync Failed at error: " .. error_msg )
    end
end)

marketplaceservice.PromptGamePassPurchaseFinished:Connect(function(plr , id , waspurch)
    if id == gamepassid and waspurch then
        print("hi")
    else
        print("play other game poor person")
    end
end)
#

thats about it

#

bye

hollow oyster
#

its fine

edgy violet
#

``lua

fallow badge
hollow oyster
#

u can have this but this is worse

edgy violet
#

yes please

edgy violet
#

if success and error_msg is a bad practice

hollow oyster
#

what

#

smh

#

s1

#

bye

fallow badge
#
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success, result = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if success then
        print("player already have gamepass")
    else
        warn(result)
    end
end
```like this ?
fallow badge
#

if success and result *

edgy violet
#

and now add

hollow oyster
#

yes

hollow oyster
#

and it works

edgy violet
#

if not success then

hollow oyster
#

bye

edgy violet
#

and just warn

#

warn(result)

fallow badge
#
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success, result = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if success and result then
        print("player already have gamepass")
    else
        warn(result)
    end
end)
#

this ? @edgy violet

edgy violet
#

if success and result then
print("player already have gamepass")
else noo.

#

if success then

hollow oyster
#

dont change anything

#

bye bye

fallow badge
#

@hollow oyster can u explain to me how p call works ?

edgy violet
#
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success, result = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if success then
        print("player already have gamepass")
    end
    if not success then
        warn(result)
    end
end)
hollow oyster
fallow badge
edgy violet
#

no

#

or actually yea

#

sure

fallow badge
#

?

hollow oyster
fallow badge
#

whhaat u make my brain confuse now

#

its no or yes ?

hollow oyster
#

yes

fallow badge
#

ok

edgy violet
#

yes

hollow oyster
#
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success, result = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if success and result then
        print("player already have gamepass")
    elseif not success then
        warn(result)
    end
end

this is it

robust quiver
#

missing basics like if statements ;o

hollow oyster
#

dont do anything else

#

bye

fallow badge
edgy violet
#
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success, result = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if success then
        print("player already have gamepass")
    elseif not success then
        warn(result)
    end
end
hollow oyster
#

bro

#

stop sending code

#

it already works

hollow oyster
fallow badge
#

i add and result ?

hollow oyster
edgy violet
hollow oyster
#

THIS DUMB S1

#

rage bait

#

ong

edgy violet
#

bro fell for it again.

hollow oyster
#

I WILL FALL FOR IT

#

HOW CAN SOMEONE BE THIS DUMB

#

YOU ARE NOT RAGE BAITING

#

YOU ARE JUST THIS DUMB IRL

#

revoke his s1

fallow badge
#

here finall script

#
local marketplaceservice = game:GetService("MarketplaceService")
local gamepassid = 1407830552
game.Players.PlayerAdded:Connect(function(plr)
    local success, result = pcall(function()
        return marketplaceservice:UserOwnsGamePassAsync(plr.UserId , gamepassid)
    end)
    
    if success and result then
        print("player already have gamepass")
    end
    if not success then
        warn(result)
    end
end)

marketplaceservice.PromptGamePassPurchaseFinished:Connect(function(plr , id , waspurch)
    if id == gamepassid and waspurch then
        print("hi")
    else
        print("play other game poor person")
    end
end)
edgy violet
#

bitch ass

hollow oyster
#

do this

fallow badge
#

so u did elseif instead of if ?

hollow oyster
#

yes

#

just use this

#

dont ask questions

fallow badge
#

oh i know why now

#

but it will work the same anyway