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

my game pass script is not working it should make a gui pop up can anyone help?

Asked by
danglt 185
5 years ago

local Gamepass = 1249117

local Player = game.Players.LocalPlayer

function onTouched(m) p = m.Parent:findFirstChild("Humanoid") if game.MarketplaceService:PlayerOwnsAsset(Player,Gamepass) then game.ServerStorage.Ask:Clone().Parent = game.Players.LocalPlayer.PlayerGui end end script.Parent:connect(onTouched)

1
You can’t access ServerStorage in a localscript. If you’re using a server script though, it still won’t work as you can’t use LocalPlayer. User#20279 0 — 5y

2 answers

Log in to vote
0
Answered by
Avigant 2374 Moderation Voter Community Moderator
5 years ago

For future reference, it makes your code much easier to read if you use the codeblock feature and properly indent and separate your code.

Game Passes work differently than other assets now and you need to use the new API for new game passes.

You'd pass in a call like this:

MarketplaceService:UserOwnsGamePassAsync(LocalPlayer.UserId, GamePassId).

Additionally, the client cannot access game.ServerStorage.

You are checking if any part with a humanoid touched the part, but that's not what you want, because other NPCs or players could touch the part.

For future reference, just call game.Players:GetPlayerFromCharacter(TouchedPart.Parent) to attempt to find the player (though it can be nil, so return if it is). Use either that or the Humanoid.Touched event for this, and make sure that you only listen for the local player touching the part.

RBXScriptSignal:connect() is deprecated, prefer RBXScriptSignal:Connect().

0
local Gamepass = 1249117 02 03 local Player = game.Players.LocalPlayer 04 05 function onTouched(m) 06 p = m.Parent:findFirstChild("Humanoid") 07 if game.MarketplaceService:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, Gamepass) then 08 print("Player Has Gamepass") 09 end 10 end 11 script.Parent:Connect(onTouched) ??? danglt 185 — 5y
Ad
Log in to vote
0
Answered by
danglt 185
5 years ago

ok so i did

local Gamepass = 1249117

local Player = game.Players.LocalPlayer

function onTouched(m)
    p = m.Parent:findFirstChild("Humanoid")
    if game.MarketplaceService:UserOwnsGamePassAsync(game.Players.LocalPlayer.UserId, Gamepass) then
        print("Player Has Gamepass")
    end
end
script.Parent:Connect(onTouched)

still is not working did i miss something you said?

Answer this question