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

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

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 comment

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.

2 answers

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().

1 comment

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) ???

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?

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