How do I get this script to also give the gamepass tools when a player respawns?
So I have this script for gamepasses, (Yes its a new one using MarketplaceService:UserOwnsGamePassAsync) It works except for when a player resets or gets respawned, it gives it to them, once, never again, how can I make it give the tool every time said player's character respawns? Heres the script.
01 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
02 | local Players = game:GetService( "Players" ) |
04 | local gamePassID = 4468725 |
06 | local function onPlayerAdded(player) |
11 | local success, message = pcall ( function () |
12 | hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID) |
17 | warn( "Error while checking if player has pass: " .. tostring (message)) |
21 | if hasPass = = true then |
26 | local tools = game.ReplicatedStorage:WaitForChild( "Tools1" ) |
27 | for i,v in pairs (tools:getChildren()) do |
29 | v:Clone().Parent = player:WaitForChild( "Backpack" ) |
30 | v:Clone().Parnet = player:WaitForChild( "StarterGear" ) |
33 | print (player.Name .. " owns the game pass with ID " .. gamePassID) |
39 | Players.PlayerAdded:Connect(onPlayerAdded) |