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

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

Asked by
Nidoxs 190
6 years ago

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)
0
Try to replace "PlayerHasPass" and make it "PlayerOwnsAsset". AirTranPilot22 2 — 6y
0
Ever tried a thing called "print debugging"? hiimgoodpack 2009 — 6y
0
@AirTranPilo22 you cannot do that as PlayerOwnsAsset only works with Clothing and such. You need to use PlayerHasPass for gamepasses. PyccknnXakep 1225 — 6y
0
I also recommend not storing things in the ServerStorage, but rather ReplicatedStorage. PyccknnXakep 1225 — 6y
0
Also, I don't see Character being used either. PyccknnXakep 1225 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

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

Ad
Log in to vote
0
Answered by 6 years ago

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!

Answer this question