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

Gamepass Script Not Giving Player Radio When They Own Radio Gamepass?

Asked by
LuaDLL 253 Moderation Voter
5 years ago
Edited 5 years ago
local GamepassService = game:GetService("GamePassService")
local ss = game:GetService("ReplicatedStorage").Tools

game.Players.PlayerAdded:Connect(function(player)
if GamepassService:PlayerHasPass(player,4982143) then
        local Boom = ss:FindFirstChild("Radio")
        Boom:Clone().Parent = player:WaitForChild("StarterGear")
        if not player:WaitForChild("Backpack"):FindFirstChild(Boom.Name) then
            Boom:Clone().Parent = player:WaitForChild("Backpack")
        end
        warn("Gave Radio To "..player.Name)
    end
end)

2 answers

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Hello, Professional_Lua!

Try this: (I'm testing...)

local GamepassService = game:GetService("GamePassService")
local ss = game:GetService("ReplicatedStorage").Tools

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char) --Add this to give the tool every time player dies...
    if GamepassService:PlayerHasPass(player,4982143) then
            local Boom = ss:FindFirstChild("Radio")
            Boom:Clone().Parent = player:WaitForChild("Backpack") --Players don't have starter gear...
            warn("Gave Radio To "..player.Name)
        end
    end)
end)

Good Luck with your games

0
Players Dont Have Starter Gears? Hmmm... https://gyazo.com/32f8a3e488ae286dbc516518915f8729 LuaDLL 253 — 5y
0
'-' I don't know how it works(new thing discovererd) Leamir 3138 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Hi! Roblox replaced the GamePassService with Marketplace Service. Try using this:

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local GamePassID = 000000  

function onPlayerSpawned(player) 

    local hasPass = false

    local success, message = pcall(function()
        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, GamePassID)
  print("Player already has Radio")
    end)

     if not success then
        warn("Error while checking if player has pass: " .. tostring(message))
        return
    end

    if hasPass == true then
  game.Lighting["Item Name"]:clone().Parent = player.Backpack
 end
end 

game.Players.PlayerAdded:Connect(function(player)
  player.CharacterAdded:Connect(function()
    onPlayerSpawned(player)
  end)
end)

Players.CharacterAdded:Connect(onPlayerSpawned)

Change the 00000 to the gamepass ID and change the "Item Name" to the name of the radio and store the item in Lighting! Hope this helps! -tawk1215

Answer this question