So I am wondering how I could make these two script compatible. Dev script that allows Developer Products give stats:
local MarketplaceService = game:GetService("MarketplaceService")
local AddHealthID = 22137556 --ENTER
local AddSpeedID = 22137544 --PASS
local AddGearID = 22137570 --IDS
local AddGear2ID = 22137564 --IDS
local AddGear3ID = 22137575 --HERE
local AddGear4ID = 22137566 --IDS
local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
MarketplaceService.ProcessReceipt = function(receiptInfo)
local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId
if PurchaseHistory:GetAsync(playerProductKey) then
return Enum.ProductPurchaseDecision.PurchaseGranted
end
for i, player in ipairs(game.Players:GetPlayers()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == AddHealthID then
player.Character.Humanoid.MaxHealth = player.Character.Humanoid.MaxHealth + 50 --Adds 50 to their current health
player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
end
if receiptInfo.ProductId == AddSpeedID then
player.Character.Humanoid.WalkSpeed = player.Character.Humanoid.WalkSpeed + 15 -- Adds 5 to their current Walkspeed
end
if receiptInfo.ProductId == AddGearID then
game.ReplicatedStorage.GravityCoil:Clone().Parent = player.Backpack -- put the gear in ReplicatedStorage then put the name of the gear in the GEARNAMEHERE
-- game.ReplicatedStorage.GEARNAMEHERE:Clone().Parent = player.StarterGear -- Add this back in if you want them to get this item till they leave the game, Like renting it
end
if receiptInfo.ProductId == AddGear2ID then
game.ReplicatedStorage.LockonLauncher:Clone().Parent = player.Backpack -- put the gear in ReplicatedStorage then put the name of the gear in the GEARNAMEHERE
-- game.ReplicatedStorage.GEARNAMEHERE:Clone().Parent = player.StarterGear -- Add this back in if you want them to get this item till they leave the game, Like renting it
end
if receiptInfo.ProductId == AddGear3ID then
game.ReplicatedStorage.JetPack:Clone().Parent = player.Backpack -- put the gear in ReplicatedStorage then put the name of the gear in the GEARNAMEHERE
-- game.ReplicatedStorage.GEARNAMEHERE:Clone().Parent = player.StarterGear -- Add this back in if you want them to get this item till they leave the game, Like renting it
end
if receiptInfo.ProductId == AddGear4ID then
game.ReplicatedStorage.EpicLaser:Clone().Parent = player.Backpack -- put the gear in ReplicatedStorage then put the name of the gear in the GEARNAMEHERE
-- game.ReplicatedStorage.GEARNAMEHERE:Clone().Parent = player.StarterGear -- Add this back in if you
end
end
end
PurchaseHistory:SetAsync(playerProductKey, true)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
My script that adds Health when you buy a Gamepass:
gps = game:GetService("GamePassService");
id = script:WaitForChild("GamePassID");
EH = script:WaitForChild("ExtraHealthAmount");
game.Workspace.ChildAdded:connect(function(char)
h=char:FindFirstChild("Humanoid")
if h~=nil then
plr=game.Players:FindFirstChild(char.Name)
if gps:PlayerHasPass(plr, id.Value) then
h.MaxHealth=EH.Value
h.Health=EH.Value
end
end
end)
When you use the Game pass it does give you +150 Health but when you try and buy +50 Health from the Dev Product it does not add anything since the Health Game pass sets the health. I need it to add the Health instead of setting it. Goulstem helped me do the same exact thing except with Speed not health and here is the script that he helped me on that works so I am figuring that the script for this on will be very similar:
local gps = game:GetService("GamePassService");
local id = script:WaitForChild("GamePassID");
local Speed = script:WaitForChild("WalkSpeedAmount");
game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(char) --CharacterAdded event
char:WaitForChild("Humanoid") --Just to be safe(;
if gps:PlayerHasPass(Player , id.Value) then
local hum = Player.Character.Humanoid
hum.WalkSpeed = hum.WalkSpeed + Speed.Value
end
end)
end)
If forgot to mention that the Health Game pass has a Value names GamePassID and ExtraHealthAmount. If you can help it would be really nice of you! Plus I want the person to have the extra health everytime the are respawned!THANKS!
By the way if you see this Goulstem sorry, I sent you a message on ROBLOX to further explain the situation and to say sorry:)
