I don’t know if it prints ingame or not, there is no output window when I play the game on the actual Roblox website. Also, the code did not move. It stayed in Server Script Service.
Shouldn’t the PlayerAdded
event be followed by the CharacterAdded
event?
You can check if it printed by pressing F9
in game and clicking on Server
I don’t think so…
Yes, you’re waiting for the player, but what about the character? You’re adding it to the Player’s backpack before its character can spawn, and when the character does spawn, it’s backpack will be defaulted to nothing.
It’s not printing anything, but I clearly do own the gamepass. Is it because I don’t have the speed coil in my inventory?
Oh wow, I never thought about that. How do I fix this issue?
Can you copy+paste the code instead of sending an image so I can tweak it without having to rewrite the whole thing? Thanks
p.s.: you should probably fix your other scripts that are generating output errors before moving on to new ones
I’m not sure how likely that is to work since it isn’t printing that @Alphenumeric owns the gamepass, even if he placed a print statement so I don’t know if connecting it to CharacterAdded
will do anything, but then again I could be wrong
Alright, there are 2 scripts, a localscript and a normal script. The localscript is in the ScreenGui Gamepass Store, and the Script is in the Server Script Service. Here are the two.
localscript:
local ScreenGui2 = script.Parent
local SprintGamepassID = 15769436
local MarketplaceService = game:GetService(“MarketplaceService”)
local MainFrame = script.Parent.MainFrame
local SprintGamepass = MainFrame.SprintGamepassFrame.SprintGamepass
local OpenShop = MainFrame.Parent.OpenShop
local player = game.Players.LocalPlayer
local Players = game:GetService(“Players”)
SprintGamepass.MouseButton1Down:Connect(function()
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, SprintGamepassID)
end)
if hasPass then
print(“you already have the gp”)
else
MarketplaceService:PromptGamePassPurchase(player, SprintGamepassID)
end
end)
OpenShop.MouseButton1Down:Connect(function()
MainFrame.Visible = not MainFrame.Visible
end)
The Server Script Service Script:
local MarketplaceService = game:GetService(“MarketplaceService”)
local SprintGamepassID = 15769436
local Players = game:GetService(“Players”)
game.Players.PlayerAdded:Connect(function(player)
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, SprintGamepassID)
end)
if hasPass then
print(player.Name…" has the gamepass")
local clone = game:GetService(“InsertService”):LoadAsset(99119158):GetChildren()[1]
clone.Handle.Anchored = false
clone.Parent = player.Backpack
end
end)
local function onPromptGamePassPurchaseFinished(player, purchasedPassId, purchaseSuccess)
if purchaseSuccess and purchasedPassId == SprintGamepassID then
print(player.Name…“has purchased the gamepass haha”)
local clone = game:GetService(“InsertService”):LoadAsset(99119158):GetChildren()[1]
clone.Handle.Anchored = false
clone.Parent = player.Backpack
end
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)
Try this. Something I noticed, is that you assigned the Players service to a variable, but never used it. That’s probably not the problem, but I want you to try this code to replace the server script.
local MarketplaceService = game:GetService(“MarketplaceService”)
local SprintGamepassID = 15769436
local Players = game:GetService(“Players”)
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, SprintGamepassID)
end)
if hasPass then
print(player.Name…" has the gamepass")
local clone = game:GetService(“InsertService”):LoadAsset(99119158):GetChildren()[1]
clone.Handle.Anchored = false
clone.Parent = player.Backpack
else
print(player.Name .. " does not have the gamepass")
end
end)
end)
local function onPromptGamePassPurchaseFinished(player, purchasedPassId, purchaseSuccess)
if purchaseSuccess and purchasedPassId == SprintGamepassID then
print(player.Name…“has purchased the gamepass haha”)
local clone = game:GetService(“InsertService”):LoadAsset(99119158):GetChildren()[1]
clone.Handle.Anchored = false
clone.Parent = player.Backpack
end
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)
Oh my gosh you are such a lifesaver. It finally worked haha. Thank you so much!