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

Why aren't these gamepass scripts working??

Hi, I'm working on a gamepass for a boat, For some reason its saying that I don't own the gamepass when I do own the gamepass, I'm wondering if Im messing something up or.. if it's just a glitch or something.

Script 1:

local id = 1249006

game.Players.PlayerAdded:connect(function(player)
    	if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
        		local BoatPass = Instance.new("BoolValue")
		BoatPass.Name = "BoatPass"
		BoatPass.Parent = player
    	end
end)

Script 2:

local boat = game.ServerStorage.SpeedBoat

function onMouseClick(player)
	if player:FindFirstChild("BoatPass") ~= nil then
		boat:Clone().Parent = game.Workspace
		wait(10)
	else
		script.Parent.Parent.SurfaceGui.TextLabel.Text = "Error, you don't own the Speedboat Gamepass."
		wait(5)
		script.Parent.Parent.SurfaceGui.TextLabel.Text = "Spawn a Speedboat."
	end
end

script.Parent.MouseClick:Connect(onMouseClick)

It keeps saying the text and not spawning the boat, even though I own the game pass, any help?

2 comments

0

?

2 answers

✓ Accepted answer

ROBLOX uses a diffrent method for checking if you own a gamepass or not. "PlayerHassPass" is no longer used, instead use UserOwnsGamePassSync.

Your script should be:

local id = 1249006

game.Players.PlayerAdded:connect(function(player)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id) then --Notice the change in both the Service and the method?
                local BoatPass = Instance.new("BoolValue")
        BoatPass.Name = "BoatPass"
        BoatPass.Parent = player
        end
end)

2 comments

0

Tried it and it still says I don't own the gamepass.

0

Apologies, I forgot that instead of (player, id), it requires (player.UserId, id)! I editted my answer, tested it myself, and seems to work.

Instead of using the local ID try to use a Value that you can put inside ur script or in a ur boat

and use this local GamePassService = Game:GetService('GamePassService')

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