Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Faster speed gamepass that i want to stack when getting more speed?

This is the speed gamepass:

local id = 8350199 
 
game:GetService("MarketplaceService").PromptGamePassPurchaseFinished:Connect(function(plr,ido,purchased)
    if purchased and ido == id then
        plr.Character.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed + 30
    end
end)
 
game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(game.Players[char.Name].UserId, id) then
            char.Humanoid.WalkSpeed = plr.Character.Humanoid.WalkSpeed + 30
        end
    end)
end)

This is the shop to understand what i am talking about: https://gyazo.com/9434acf5beec38d50a6ed356adc0a9b3

When i join the game i get the +30 walkspeed from the speed gamepass but then if i buy +6 speed in the shop it goes back to the default walkspeed + 6.

This is the script for the shop when i equip the speed from the shop:

local char = script.Parent.Parent
local hum = char:FindFirstChild("Humanoid")
local pet = script.Parent
local maxFloat = 0.5
local floatInc = 0.025
local sw = false
local fl = 0
local head = char:FindFirstChild("Head")

hum.WalkSpeed = 16 + 6

I want this gamepass id (8350199) to stack when buying speed. So that if i but +6 speed from the shop the gamepass speed +30 also stacks so it is +36.

Hope this is understandable and would appreciate if someone could help me to what i should add to the script above.

Like for example

local char = script.Parent.Parent
local hum = char:FindFirstChild("Humanoid")
local pet = script.Parent
local maxFloat = 0.5
local floatInc = 0.025
local sw = false
local fl = 0
local head = char:FindFirstChild("Head")

hum.WalkSpeed = 16 + 6

if 8350199 then
.........

5 comments

0

Instead of using 16 + 6, do hum.WalkSpeed = hum.WalkSpeed + 6. To add to the current walkspeed instead of resetting it to 16 then adding 6

0

I already tried that MrLonely.

0

Then it still don't stack the +30 from the gamepass. Are there anything i could write in the script like if the local player hum.WalkSpeed = 16 + 6 + 30? has that gamepass then the player gets

0

And i shouldn't say hum.WalkSpeed = hum.WalkSpeed + 6 because then you can litterally just stack it as many times you want to in the shop

0

It should work. If you are having trouble with it stacking as much as the player wants, just make another question.

1 answer

local char = script.Parent.Parent
local hum = char:FindFirstChild("Humanoid")
local pet = script.Parent
local maxFloat = 0.5
local floatInc = 0.025
local sw = false
local fl = 0
local head = char:FindFirstChild("Head")

hum.WalkSpeed = hum.WalkSpeed + 6

This is very simple! All you have to do is get the players current walk speed and add 6 to it. That way, if they have the gamepass, it will stack. I made this answer so that the question is labeled as answered. Hope this helps you!

Best

TheLastHabanero

This discussion is preserved as it was. New answers, comments, and votes are closed.