0

# Why Is This Script That Gives Gamepasses Only Give The Items When The Player Leaves And Rejoins?

I have a script that is supposed to give gamepasses when the player clicks a button.

(local button script)

script.Parent.MouseButton1Click:Connect(function()
game:GetService("MarketplaceService"):PromptGamePassPurchase(game.Players.LocalPlayer,15413257)
end)


(gamepass giving script, in workspace)

local MarketPlaceService = game:GetService("MarketplaceService")

if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, 15413257) then

game.ServerStorage.Tools.SpeedCoil:Clone().Parent = player:WaitForChild("Backpack")
game.ServerStorage.Tools.SpeedCoil:Clone().Parent = player:WaitForChild("StarterGear")
end
end)


The scripts work but the gamepass giving script only gives the speed coil when the player rejoins the game, but I want it to give the weapon to the player instantly. (Putting the speed coil in replicated storage breaks the speed coil.) Please help.

Thank you!

1

Players.PlayerAdded only fires when the player joins for the first time. If you want the coil to clone to the player's backpack every time they spawn, you can use the player's CharacterAdded property

local MarketPlaceService = game:GetService("MarketplaceService")

if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, 15413257) then
game.ServerStorage.Tools.SpeedCoil:Clone().Parent = player:WaitForChild("Backpack")
end
end)
end)