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") game.Players.PlayerAdded:Connect(function(player) 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!
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") game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, 15413257) then game.ServerStorage.Tools.SpeedCoil:Clone().Parent = player:WaitForChild("Backpack") end end) end)