I was working on a script that gives you a DarkHeart when you buy the gamepass. However, it doesn’t give you anything. How exactly would I fix this?
local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassId = 20246474
local Tool = script.Darkheart
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
local ToolClone = Tool:Clone()
ToolClone.Parent = Player.Backpack
end
end)
end)
add a print after the if statement to see if its printing > if not you can troubleshoot that line.
Actually I think what your problem really is > is your variables. I think your script is like cloning the variable? if that makes sense. Idk its really weird.
local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassId = 20246474
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
local ToolClone = script.Darkheart:Clone()
ToolClone.Parent = Player.Backpack
end
end)
end)
the reason you do not get the sword is because you do not own the gamepass, if you use a gamepass id you own/created, you should get it, i tried this out, and it worked.
local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassId = 20286552 -- REPLACE 1234567 WITH YOUR GAMEPASS ID
local Tool = script.Darkheart -- REPLACE GravityCoil WITH THE NAME OF YOUR TOOL
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
while wait() do
if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
local ToolClone = Tool:Clone()
ToolClone.Parent = Player.Backpack
break
end
end
end)
end)