Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I make these 2 scripts compatible?

Asked by 10 years ago

So I have this script here to add speed when they join if they have a certain gamepass and it works completely:

01gps = game:GetService("GamePassService");
02 
03id = script:WaitForChild("GamePassID");
04Speed = script:WaitForChild("WalkSpeedAmount");
05 
06game.Players.PlayerAdded:connect(function(Player)
07Player:WaitForDataReady()
08if gps:PlayerHasPass(Player , id.Value) then
09coroutine.resume(coroutine.create(function()
10while wait() do
11repeat wait() until Player.Character~=nil
12Player.Character:WaitForChild("Humanoid").WalkSpeed=Speed.Value
13end
14end))
15end
16end)

There is a GamePassID inside of the script and also the SpeedAmount. That all works fine and dandy but then when I use my Dev product scripts there is a problem. My Dev script gives speed, health, etc. when you buy that certain Dev product. It does at speed and everything its just when you have a gamepass that adds speed it does not add anything for some reason. It may be a MarketPlace error? Dev Script:

01local MarketplaceService = game:GetService("MarketplaceService")
02local AddHealthID = 22137556 --ENTER
03local AddSpeedID = 22137544  --PASS
04local AddGearID = 22137570   --IDS
05local AddGear2ID = 22137564   --IDS
06local AddGear3ID = 22137575  --HERE
07local AddGear4ID = 22137566   --IDS
08local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
09MarketplaceService.ProcessReceipt = function(receiptInfo)
10    local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId
11    if PurchaseHistory:GetAsync(playerProductKey) then
12        return Enum.ProductPurchaseDecision.PurchaseGranted
13    end
14    for i, player in ipairs(game.Players:GetPlayers()) do
15        if player.userId == receiptInfo.PlayerId then
View all 43 lines...

If you could help me and make these two script compatible it would be really nice of you, THANKS!

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

So your problem is that if you've bought the Developer Product, the GamePass functions don't work?

This might be due to the fact that you're Setting the WalkSpeed value, rather than actually adding it.

So standard WalkSpeed is 16? Your Dev Product adds 15, from that moment it's 31. So since you're SETTING the WalkSpeed in the gamepass functions..

Speed = script:WaitForChild("WalkSpeedAmount");

Player.Character:WaitForChild("Humanoid").WalkSpeed = Speed.Value

If Speed's value is 31(or 30, since that makes more sense), then you won't see any change.

So to fix this? Add the WalkSpeed rather than Setting it.

01local gps = game:GetService("GamePassService");
02local id = script:WaitForChild("GamePassID");
03local Speed = script:WaitForChild("WalkSpeedAmount");
04 
05game.Players.PlayerAdded:connect(function(Player)
06    Player:WaitForDataReady()
07    if gps:PlayerHasPass(Player , id.Value) then
08        coroutine.resume(coroutine.create(function()
09            while wait() do
10                repeat wait() until Player.Character~=nil
11                local hum = Player.Character.Humanoid
12                hum.WalkSpeed = hum.WalkSpeed + Speed.Value
13            end
14        end))
15    end
16end)
0
This works but it makes my go way to fast even when I changed the Walkspeedamount. TixyScripter 115 — 10y
0
I see the problem it constantly adds it instead of adding the speed only once! But i dont know how to fix... TixyScripter 115 — 10y
Ad

Answer this question