Could someone help me figure out how I would go about scripting a combo bar for my clicker game?
1 Like
What exactly is a “combo bar”?
2 Likes
When you click the button your combo goes up and it multiply your stats but when you stop clicking your combo slowly goes down and the longer you dont click the faster your combo goes down
1 Like
Hi, this is my code:
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local ctime = tick()
local t_combo = 0.5
local combo = 1
local m_down = 2
local TextLabel = script.Parent.TextLabel
TextLabel.Visible = false
function show_combo(value)
spawn(function()
local text = TextLabel:Clone()
text.Text = "+" .. value
text.Visible = true
text.Parent = TextLabel.Parent
for y = 1, 50 do
text.Position = UDim2.new(0.5, 0, 0.5, -y * 5)
wait()
end
text:Destroy()
end)
end
mouse.Button1Down:Connect(function()
print("Down")
local click_time = tick()
local diff = click_time - ctime
if diff <= t_combo then
combo = combo + 1
show_combo(combo)
else
combo = combo - (math.ceil(diff * m_down))
if combo < 1 then
combo = 1
end
show_combo(combo)
end
ctime = click_time
end)
Example:
And the file: ClickerCombo.rbxl (23,5 KB)
4 Likes