Hello, I am making a giver, Instead of using a touch script I wanted to use a button because the touch script has issues where it fills the backpack. My issue, is that the button wont do its function once clicked. here is the script.
local debounce = false
local gamePassId = 445136135
local passService = game:GetService("MarketplaceService")
function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
script.Parent.ClickDetector.MouseClick:connect(function(PlayerPart)
local Player = game.Players:GetPlayerFromCharacter(PlayerPart.Parent)
local human = PlayerPart.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false and passService:PlayerOwnsAsset(Player, gamePassId)then
print("Player is a VIP!")
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
game.ReplicatedStorage.Store.Tools.Vip_Wand:clone().Parent = player.Backpack
wait(2)
debounce = false
end
end)
There is a Click Detector in the scripts parent. What did I do wrong?
