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

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

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

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

2 comments

0

Players Dont Have Starter Gears? Hmmm... https://gyazo.com/32f8a3e488ae286dbc516518915f8729

0

'-' I don't know how it works(new thing discovererd)

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

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