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

Why does my gamepass script not work, even when I've bought the gamepass?

The Gamepass IDs are correct, and I've bought my own gamepass, for 50 ROBUX but it doesn't give me the Gamepass tool.

--Nidoxs
local DaggerId = 1000438124
local DaggerTool = game.ServerStorage.GamepassTools.Dagger
local GreatswordId = 1000442559
local GreatSTool = game.ServerStorage.GamepassTools.Greatsword

local GPS = game:GetService("GamePassService")

game.Players.PlayerAdded:connect(function(Player)
	Player.CharacterAdded:connect(function(Character)
		if GPS:PlayerHasPass(Player,DaggerId) then
			local ToolForPlayer = DaggerTool:Clone()
			ToolForPlayer.Parent = Player:WaitForChild("Backpack")
		end
		if GPS:PlayerHasPass(Player, GreatswordId) then
			local ToolForPlayer = GreatSTool:Clone()
			ToolForPlayer.Parent = Player:WaitForChild("Backpack")
		end
	end)
end)

5 comments

0

Try to replace "PlayerHasPass" and make it "PlayerOwnsAsset".

0

Ever tried a thing called "print debugging"?

0

@AirTranPilo22 you cannot do that as PlayerOwnsAsset only works with Clothing and such. You need to use PlayerHasPass for gamepasses.

0

I also recommend not storing things in the ServerStorage, but rather ReplicatedStorage.

0

Also, I don't see Character being used either.

2 answers

You should tell us the errors when something doesn't work by pressing F9 (opens Developper Console)

I assume it doesn't work because your Dagger and Greatsword aren't loaded fast enough, add a WaitForChild() WaitForChild on Backpack is useless. Backpack will always be loaded very quickly

Instead of cloning the tools in the backpack inside of a CharacterAdded event, you should of just cloned the tools in the StarterGear (which is inside of the player) to make it so it is always present, even when you die

I would recommend cloning the weapons into StarterGear instead of Backpack, as F4ULT1NTH3D4T4 said.

local DaggerId = 1000438124
local GreatSId = 1000442559
local DaggerTool = game.ServerStorage.GamepassTools.Dagger:Clone()
local GreatSTool = game.ServerStorage.GamepassTools.Greatsword:Clone()
game.Players.PlayerAdded:Connect(function(player)
	if game:GetService("GamePassService"):PlayerHasPass(player, DaggerId) then
		DaggerTool.Parent = player.StarterGear
		else print("Player does not have gamepass") end
	if game:GetService("GamePassService"):PlayerHasPass(player, GreatSId) then
		GreatSTool.Parent = player.StarterGear
	else print("Player does not have gamepass") end
end)

This has been tested, and it works 100%. If this helped, please accept my answer! Thanks!

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