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
- local GamepassName = v.ItemName.Value
- 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 items:IsA("Tool") and player.Backpack:FindFirstChild(items) and items.Name == GamepassName then
- print(GamepassName)
- print(items)
- for i,items2 in pairs(player.StarterGear:GetChildren()) do
- if items2:IsA("Tool") and items2.Name == items.Name then
- print(items2)
- items:Destroy()
- items2:Destroy()
- break
- end
- end
- end
- if items:IsA("Tool") and not player.Backpack:FindFirstChild(items) then
- print("hi")
- items = GamepassName
- print(items)
- for i,itemsinstorage in pairs(ItemLocation:GetChildren()) do
- if itemsinstorage.Name == items then
- print(itemsinstorage)
- local item1 = itemsinstorage:Clone()
- item1.Parent = player.Backpack
- local item2 = itemsinstorage:Clone()
- item2.Parent = player.StarterGear
- end
- end
- 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
- break
- end
- end
- wait(1)
- debounce = true
- end
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement