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

Enabling new stats when gamepass is brought and disabbling the old stats for the gamepass user?

Asked by 4 years ago

I am currently confused, I have set up my script to be able to purchase a game-pass: "local plr = game.Players.LocalPlayer local button = script.Parent local MarkerplaceService = game:GetService("MarketplaceService") script.Parent.MouseButton1Click:Connect(function() MarkerplaceService:PromptGamePassPurchase(plr, 3453741) --Add gamepass ID end)"

I want to be able to make it so that when the gamepass is brought I can make my player earn 2 times the jumps, when the gamepass is enabled. Here is the script for before the gamepass is enable: "local datastore = game:GetService('DataStoreService'):GetDataStore('JumpingSimulatorStore#4') local increaseEvent = game:GetService('ReplicatedStorage'):WaitForChild('Increased') local DisplayPlus = game:GetService('ReplicatedStorage'):WaitForChild('DisplayPlus') local ItemWornEvent = game:GetService('ReplicatedStorage'):WaitForChild('ItemWorn') local ItemRemovedEvent = game:GetService('ReplicatedStorage'):WaitForChild('ItemRemoved') print('update: 5')

game.Players.PlayerAdded:Connect(function(player) local stats = Instance.new('Folder', player) stats.Name = 'leaderstats'

    local jumpCount = Instance.new('NumberValue')
    jumpCount.Name = 'Jump Count'
    jumpCount.Parent = stats

    local cash = Instance.new('NumberValue')
    cash.Name = 'Cash'
    cash.Parent = stats

    local size = Instance.new('NumberValue', player)
    size.Name = 'Size'

    local key1 = 'Player: '.. player.UserId

    local savedPoints1 = datastore:GetAsync(key1)

    if savedPoints1 then
        size.Value = savedPoints1[1]
        jumpCount.Value = savedPoints1[2]
        cash.Value = savedPoints1[3]
    else
        print('Never played before')
        jumpCount.Value = 2
        size.Value = 0.2
        local ValuesToSave = {0.2, jumpCount.Value, cash.Value} -- size, jump count, cash
        datastore:SetAsync(key1, ValuesToSave)
    end

    game.Workspace.Spawns.ConfettiCannon1.Script.Disabled = true
    game.Workspace.Spawns.ConfettiCannon1.Script.Disabled = false
    game.Workspace.Spawns.ConfettiCannon2.Script.Disabled = true
    game.Workspace.Spawns.ConfettiCannon2.Script.Disabled = false

    local inventory = Instance.new('Folder')
    inventory.Name = 'Inventory'
    inventory.Parent = player

    local playerFolder = Instance.new('Folder')
    playerFolder.Name = player.Name
    playerFolder.Parent = game:GetService('ReplicatedStorage').Players

    local key2 = 'Inventory: '.. player.UserId

    local savedPoints2 = datastore:GetAsync(key2)

    if savedPoints2 then
        print('saved')
        print(savedPoints2[1])
        for i = 1, #savedPoints2 do
            local item = game:GetService('ReplicatedStorage').ItemList:FindFirstChild(savedPoints2[i])

            if item then
                local item1 = item:Clone()
                item1.Parent = inventory

                local item2 = item:Clone()
                item2.Parent = playerFolder
            else
                print('Item Not Found!')
            end
        end
    end

player.CharacterAdded:Connect(function(character)
    character.Humanoid.JumpPower = jumpCount.Value / 50 + 50
    character.Humanoid.WalkSpeed = jumpCount.Value / 200 + 10
    character.Humanoid:WaitForChild('BodyDepthScale').Value = size.Value
    character.Humanoid:WaitForChild('BodyWidthScale').Value = size.Value
    character.Humanoid:WaitForChild('HeadScale').Value = size.Value

    if size.Value >= 1 then
        character.Humanoid:WaitForChild('BodyHeightScale').Value = size.Value
    else
        character.Humanoid:WaitForChild('BodyHeightScale').Value = 1
    end

    if size.Value >= 1 then
        character.Humanoid:WaitForChild('HeadScale').Value = size.Value
    else
        character.Humanoid:WaitForChild('HeadScale').Value = 1
    end
end)

end)

increaseEvent.OnServerEvent:Connect(function(player, amount) if player.character then for i = 1, amount do local size = player.Size local character = player.Character character.Humanoid.JumpPower = 0 player.leaderstats['Jump Count'].Value = player.leaderstats['Jump Count'].Value + 1 size.Value = player.Size.Value + 0.001

    DisplayPlus:FireClient(player)

    wait(0)
    character.Humanoid:WaitForChild('BodyDepthScale').Value = size.Value
    character.Humanoid:WaitForChild('BodyWidthScale').Value = size.Value
    character.Humanoid:WaitForChild('HeadScale').Value = size.Value

    character.Humanoid.JumpPower = 0

    if size.Value >= 1 then
        character.Humanoid:WaitForChild('BodyHeightScale').Value = size.Value
    else
        character.Humanoid:WaitForChild('BodyHeightScale').Value = 1
    end

    if size.Value >= 1 then
        character.Humanoid:WaitForChild('HeadScale').Value = size.Value
    else
        character.Humanoid:WaitForChild('HeadScale').Value = 1
    end
end
end

end)

ItemWornEvent.OnServerEvent:Connect(function(player, item) local items = player.Character[item.BodyPart.Value]:GetChildren()

if #items >= 1 then
    for i, child in ipairs(items) do
        if child.ClassName ~= 'Vector3Value' and child.ClassName ~= 'Motor6D' and child.ClassName ~= 'Attachment' then
            child:Destroy()
        end
    end
end
local CloneItem = item:Clone()
CloneItem.Parent = player.Character[item.BodyPart.Value]
if CloneItem.ClassName == 'Model' then
    for i, child in ipairs(CloneItem:GetChildren()) do
        local clone = child:Clone()
        clone.Parent = CloneItem.Parent
    end
end

end)

ItemRemovedEvent.OnServerEvent:Connect(function(player, item) local items = player.Character[item.BodyPart.Value]:GetChildren()

if #items >= 1 then
    for i, item in ipairs(items) do
        if item.ClassName ~= 'Vector3Value' and item.ClassName ~= 'Motor6D' and item.ClassName ~= 'Attachment' then
            item:Destroy()
        end
    end
end

end)"

Please if anyone can help contact me on discord - Legitimatly#9271

0
I mean I wanna increase the jump stats to earn 2x but then also enable the orignal one, as right now I can only make it so that without the gamepass im making 2xjumps and I wanna make it so u only can with the gamepass LegitimataIy 0 — 4y

Answer this question