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
6 years ago
Edited 6 years ago
01local GamepassService = game:GetService("GamePassService")
02local ss = game:GetService("ReplicatedStorage").Tools
03 
04game.Players.PlayerAdded:Connect(function(player)
05if GamepassService:PlayerHasPass(player,4982143) then
06        local Boom = ss:FindFirstChild("Radio")
07        Boom:Clone().Parent = player:WaitForChild("StarterGear")
08        if not player:WaitForChild("Backpack"):FindFirstChild(Boom.Name) then
09            Boom:Clone().Parent = player:WaitForChild("Backpack")
10        end
11        warn("Gave Radio To "..player.Name)
12    end
13end)

2 answers

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

Hello, Professional_Lua!

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

01local GamepassService = game:GetService("GamePassService")
02local ss = game:GetService("ReplicatedStorage").Tools
03 
04game.Players.PlayerAdded:Connect(function(player)
05    player.CharacterAdded:Connect(function(char) --Add this to give the tool every time player dies...
06    if GamepassService:PlayerHasPass(player,4982143) then
07            local Boom = ss:FindFirstChild("Radio")
08            Boom:Clone().Parent = player:WaitForChild("Backpack") --Players don't have starter gear...
09            warn("Gave Radio To "..player.Name)
10        end
11    end)
12end)

Good Luck with your games

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

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

01local MarketplaceService = game:GetService("MarketplaceService")
02local Players = game:GetService("Players")
03 
04local GamePassID = 000000 
05 
06function onPlayerSpawned(player)
07 
08    local hasPass = false
09 
10    local success, message = pcall(function()
11        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, GamePassID)
12  print("Player already has Radio")
13    end)
14 
15     if not success then
View all 31 lines...

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