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

I am trying to make gamepasses work for my game but they seem broken can someone help me?

Asked by 4 years ago

It only gives the normal sword and if you own a gamepass it doesnt give you the sword

local ServerStorage=game.ServerStorage
local idA=1122
local idB=645646
local idC=615165
local service=game:GetService("MarketplaceService")
for i, plr in pairs(plrs) do
    if plr then
        character = plr.Character
        if character then

        character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame + Vector3.new(0,10,0)
            table.remove(AvailableSpawnPoints,1)

local havesword=false
if service:UserOwnsGamePassAsync(plr.UserId, idA) then
    --pass stuff
    local TrailSword = ServerStorage.TrailSword:Clone()
    TrailSword.Parent = plr.Backpack  --by puting it in back pack the player will always have it even when the respawn
    havesword=true --if sword
end
if service:UserOwnsGamePassAsync(plr.UserId, idB) then
    local Boombox = ServerStorage.Boombox:Clone()
    Boombox.Parent = plr.Backpack
end
if service:UserOwnsGamePassAsync(plr.UserId, idC) then
    local BurningSword = ServerStorage.BurningSword:Clone()
    BurningSword.Parent = plr.Backpack 
    havesword=true --if sword 
    end
    if havesword==false then
        local Sword = ServerStorage.Sword:Clone()
        Sword.Parent = plr.Backpack
        local GameTag = Instance.new("BoolValue")
         GameTag.Name = "GameTag"
        GameTag.Parent = plr.Character
end

    else
     if not plr then
                    table.remove(plrs,i)
               end
    end

end
end
0
is there any errors? tylergoatboy 82 — 4y
0
nope the game works perfectly fine just the gears that you have to buy never show up in your backpack Nistrict 44 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

plrs is not defined, so an error should be being generated. If not, that implies that the script isn't running at all. Make sure it's a normal Script in the Workspace/ServerScriptService (as documented here: https://developer.roblox.com/en-us/api-reference/class/Script)

Even if you define plrs, your code doesn't connect to any events, so it will only check for players that are in the server when the server starts. Use https://developer.roblox.com/en-us/api-reference/event/Players/PlayerAdded instead so that you can check each player as they enter the server.

Ad
Log in to vote
0
Answered by 4 years ago

I think one issue may be with the way you've used clone(), maybe try defining each gear like you have, but cut off the clone() part at the end. Then try doing (for example, the line after you have defined TrailSword): Trailsword:Clone(), then the line below as you have done, Trailsword.Parent = plr.backpack.

Let me know if this has any effect!

Answer this question