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

How to Double a boost value?

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)

11 comments

0

Send your current code

0

send

0

i need at the end that it's x2

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?

0

add 1 to player then multiply it by 2

0

So replace line 13 with cash.Value = (cash.Value + 1) * 2

0

i mean when i click with my tool i get 1 coin + the boost from the pets and then multiply it by 2

0

thanks for your help the answer was the *2 xd i doesn't knowed that

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

0

cash.Value = cash.Value + 1 *2 + boost.Value *2 works too

1 answer

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

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