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

How to Double a boost value?

Asked by
FelixDM -5
4 years ago
Edited 4 years ago

I have a game with my friends and we are trying to do a tool that do coins x2 and we need to double boost values. e.g. get 1 coin per click and that x2

local Tool = script.Parent
local hold = false
local deb = false   
local player = Tool.Parent:IsA("Model") and game.Players:GetPlayerFromCharacter(Tool.Parent) or Tool.Parent.Parent
local char = player.Character
function Press()
    if player and player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Coins") and player:FindFirstChild("CoinBoost") then
        local stats = player:WaitForChild("leaderstats")
        local cash = stats:WaitForChild("Coins") 
            local boost = player:WaitForChild("CoinBoost") --// this is pet boost
                local pgui = player:WaitForChild("PlayerGui")
                    local gui = pgui:WaitForChild("ToolPopUp")
                    cash.Value = cash.Value + 1 + boost.Value
                gui:WaitForChild("Load"):TweenSize(UDim2.new(0.241, 0,0.1, 0), "Out" , "Linear", 0.5,false,function()
            gui:WaitForChild("Load").Size = UDim2.new(0.008, 0,0.1, 0)
        end)
    end
end
game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        if player:WaitForChild("PlayerGui"):FindFirstChild("ToolPopUp") then
            player["PlayerGui"].ToolPopUp:Destroy()
            hold = false
        end
    end)
end)
script.Parent.Equipped:Connect(function()
    local char = script.Parent.Parent
    local plr = game.Players:GetPlayerFromCharacter(char)
    local gui = script:FindFirstChild("ToolPopUp")
    if gui then
        if not plr:WaitForChild("PlayerGui"):FindFirstChild("ToolPopUp") then
            gui:Clone().Parent = plr:WaitForChild("PlayerGui")
        end
    end
end)
script.Parent.Unequipped:Connect(function()
    hold = false
    local plr = script.Parent.Parent.Parent
    if plr:WaitForChild("PlayerGui"):FindFirstChild("ToolPopUp") then
        plr:WaitForChild("PlayerGui"):FindFirstChild("ToolPopUp"):Destroy()
    end
end)
script.Parent.Deactivated:Connect(function()
    hold = false
end)
script.Parent.Activated:Connect(function()
if deb == false and hold == false then
        local character = Tool.Parent;
    local humanoid = character.Humanoid
    if humanoid == nil then return end
    hold = true
    repeat
    wait()
    if deb == false then
        deb = true 
        Press()
        wait(0.5)
        deb = false
    end
    until hold == false
    end
end)
0
Send your current code 174gb 290 — 4y
0
send FelixDM -5 — 4y
0
i need at the end that it's x2 FelixDM -5 — 4y
0
I'm having a bit of trouble understanding what you are asking. Are you asking how do you multiply 1 by 2 then add to player coins, or are you asking how do you add 1 to player then multiply it by 2? beeswithstingerss 41 — 4y
View all comments (7 more)
0
add 1 to player then multiply it by 2 FelixDM -5 — 4y
0
So replace line 13 with cash.Value = (cash.Value + 1) * 2 beeswithstingerss 41 — 4y
0
i mean when i click with my tool i get 1 coin + the boost from the pets and then multiply it by 2 FelixDM -5 — 4y
0
thanks for your help the answer was the *2 xd i doesn't knowed that FelixDM -5 — 4y
0
cash.Value = (cash.Value + 1 + boost.Value) * 2 or cash.Value = cash.Value + ((1 + boost.Value) * 2) depending on what you want to happen beeswithstingerss 41 — 4y
0
cash.Value = cash.Value + 1 *2 + boost.Value *2 works too FelixDM -5 — 4y

1 answer

Log in to vote
0
Answered by
FelixDM -5
4 years ago

cash.Value = cash.Value + 1 *2 + boost.Value *2 :)

Ad

Answer this question