What do you want to achieve? A combo system, that detects every 3 times you click, then it prints “COMBO”
What is the issue? I can only make it work for 3 punches.
What solutions have you tried so far? I’ve been looking for about 30 minutes now throughout a-lot of websites, and either search algorithms are bad, or as it seems, that no one has posted about this.
Here is a snippet of my code (I don’t want to show it all because someone might steal)
local plr = game:GetService("Players").LocalPlayer
local punches = plr.Backpack.LocalScript.Punches
script.Parent.Text = ("Punches: ").. punches.Value
punches.Changed:Connect(function()
script.Parent.Text = ("Punches: ").. punches.Value
checkCombo()
end)
function checkCombo()
if punches.Value == 3 then
print("COMBO!")
script.Parent.Text = ("COMBO!")
wait(3)
script.Parent.Text = ("Punches: ").. punches.Value
end
end
Basically, there is a NumberValue inside a localscript in the player’s backpack, and it detects if the mouse clicks, if so, increase the value.
SHORT: HELP ME MAKE A ALGORITHM OR SOMETHING TO CHECK IF THE NUMBER OF PUNCHES IS A MULTIPLE OF THREE
Use the modulus operator %. If a%b == 0 then you know a is a multiple of b. Also, the "Punches: " and "COMBO!" strings do not need to be in parentheses.
No. % is the modulus operator. It returns the remainder of two numbers after division. When you divide, say, 6 by 3, you get 2 with no remainder. So, 6%3 == 0.
function checkCombo()
if punches.Value == 3%12 == 0
print("COMBO!")
script.Parent.Text = ("COMBO!")
wait(3)
script.Parent.Text = ("Punches: ").. punches.Value
end
end
I really don’t understand how I incorporate this… I feel stupid but idk how I’m gonna make it know if the value is a multiple of 3…
Ok, so it worked! Thanks, I really gotta get better at math for this stuff, and get my brain working again. All this quarantine ain’t doing the best for me lol. Your awesome, I will try understanding this!