Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game.Players
- local MarkeplaceService = game:GetService("MarketplaceService")
- local ItemGivers = game.Workspace.CoilsModel.Model -- the model with all the touchpads
- local ItemLocation = game.ReplicatedStorage.GamepassItems -- the location of the tools in replicate storage
- local Items = {"GravityCoil","AccelerationCoil","BoomBox","FlyingCarpet","FlyingCloud"} -- a random table test
- local debounce = true
- for i,v in pairs(ItemGivers:GetDescendants()) do
- --print(v)
- if v:IsA("Part") and v.Name == "Giver" then
- print(v)
- v.Touched:Connect(function(hit)
- local player = Players:GetPlayerFromCharacter(hit.Parent)
- if player and debounce then
- debounce = false
- local GamepassId = v.Gamepass.Value -- an int value that is taken from the part thats touched
- local GamepassName = v.ItemName.Value -- a string value that is taken from the part thats touched
- local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,GamepassId)
- print(player)
- print(GamepassId)
- print(GamepassName)
- print(ownsGamepass)
- if not ownsGamepass then
- local Purchase = game:GetService("MarketplaceService"):PromptGamePassPurchase(player,GamepassId)
- --print(Purchase)
- end
- if ownsGamepass then
- print("owned")
- for i,items in pairs(player.Backpack:GetChildren()) do
- print(items.Name)
- if GamepassName == player.Backpack:FindFirstChild(items.Name) then
- print(GamepassName)
- print(items)
- for i,items2 in pairs(player.StarterGear:GetChildren()) do
- if GamepassName == player.Backpack:FindFirstChild(items.Name) then
- print(items2)
- items:Destroy()
- items2:Destroy()
- break
- end
- end
- break
- end
- if GamepassName ~= player.Backpack:FindFirstChild(items.Name) then -- GamepassName ~= items.Name or
- print("hi")
- -- items = GamepassName
- print(items)
- for i,itemsinstorage in pairs(ItemLocation:GetChildren()) do
- if itemsinstorage:IsA("Tool") and itemsinstorage.Name ~= items.Name then
- print(itemsinstorage)
- local item1 = itemsinstorage:Clone()
- item1.Parent = player.Backpack
- local item2 = itemsinstorage:Clone()
- item2.Parent = player.StarterGear
- break
- end
- end
- debounce = true
- end
- --[[elseif player.Backpack:FindFirstChild(Items) ~= GamepassName then
- print("hi")
- for i,itemsinstorage in pairs(ItemLocation:GetChildren()) do
- print(itemsinstorage)
- itemsinstorage = GamepassName
- print(itemsinstorage)
- if itemsinstorage == GamepassName then
- print(itemsinstorage)
- local item1 = itemsinstorage:Clone()
- item1.Parent = player.Backpack
- end
- break
- end
- break
- end
- --[[ if Items ~= GamepassName then
- print(GamepassName)
- print(items.Name)
- local item1 = ItemLocation:FindFirstChild("GamepassName"):Clone()
- item1.Parent = player.Backpack
- local item2 = items:Clone()
- item2.Parent = player.StarterGear
- end --]]
- -- break
- end
- end
- wait(1)
- debounce = true
- end
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement