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

Give item to player if they have the gamepass?

I have this script that I want to make give the player an item when they click it(only if they have the gamepass), and yes I'm sure there could be some way that you could use for i = 1.60 +1 do for the countdown but I typed it all out instead.

local gamepass = script:WaitForChild("4835177") --the gamepass id
	
)
local item = game:GetService("ReplicatedStorage"):WaitForChild("Bloxy Cola")
local service = game:GetService("GamePassService")
local db = true


script.Parent.MouseClick:Connect(function(hit) -- idk if i should use hit here
	if service:PlayerHasPass(player,gamepass.Value) then -- if they have the gamepass

     item:Clone().Parent = player.Backpack 
wait(1)
     


script.Parent.BillboardGui.TextBox.Text = "60"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "59"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "58"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "57"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "56"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "55"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "54"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "53"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "52"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "51"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "50"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "49"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "48"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "47"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "46"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "45"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "44"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "43"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "42"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "41"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "40"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "39"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "38"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "37"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "36"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "35"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "34"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "33"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "32"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "31"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "30"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "29"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "28"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "27"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "26"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "25"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "24"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "23"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "22"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "21"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "20"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "19"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "18"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "17"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "16"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "15"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "14"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "13"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "12"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "11"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "10"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "9"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "8"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "7"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "6"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "5"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "4"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "3"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "2"
wait(1)
script.Parent.BillboardGui.TextBox.Text = "1"
wait(1)
script.Parent.BillboardGui.TextBox.Text = " "
script.Parent.Transparency=1
wait(1)
script.Parent.Transparency=0


     db = true
end
end

1 comment

0

But why would you type it all out? There's literally no benefit. for i = 60, 1, -1 do script.Parent.BillboardGui.Textbok.Text = tostring(i) wait(1) end

1 answer

✓ Accepted answer

###The PlayerHasPass method of GamePassService is broken due to the new game pass update. Use UserOwnsGamePassAsync instead. Also, if you knew you could use a for loop, why didn't you use it? How did you even have the patience to write that?!

local PassId = script["4835177"]
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local BloxyCola = ReplicatedStorage:WaitForChild("Bloxy Cola")

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    if MarketplaceService:UserOwnsGamePassAsync(player.UserId, PassId.Value) then
        BloxyCola:Clone().Parent = player.Backpack
        
        for i = 60, 1, -1 do
            script.Parent.BillboardGui.TextBox.Text = tostring(i)
            wait(1)
        end
    end
end)

4 comments

0

I checked to make sure all of the names were correct and they are but it doesn't work for me :(

0

are you still active?

0

yes

0

your script looks like it would work to me? if I put it in my game and make it a child of the item brick it shows the click detector cursor but will not give me anything now that I'm using your script

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