You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
Im trying to make a killstreak system that activates certain phases when you hit a number of kills
What is the issue? Include screenshots / videos if possible!
this code below, only runs when the kills reach 6, but not 5 (5 being the intended trigger)
elseif kills >= 5 and kills < 10 then
print("5")
EquipMod.Basic(phase1.Particles,char)
else
as clearly shown, its supposed to run when its more then OR equal to 5 (shown by “>=”) and under 10
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
ive tried seperating it by making it an or statment, (for instance: if kills == 5 or kills > 5), still had same behavior
and yes, the kills value is correctly updating, i checked.
If you require any info, please ask!
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
Indexing a dictionary would be a better approach, in my opinion. You can change it the way you like.
local kills = 0
local arr = {
[10] = function() print("10 kills") end,
[30] = function() print("30 kills") end,
[50] = function() print("50 kills") end,
}
while kills < 60 do
local fn = arr[kills]
if fn then
fn();
end
kills += 1
end
and, by any chance would there be a way to fire the function if the number is skipped, sometimes if the suer gains kills to quickly, roblox dosent register it, so id like to make sure that the function is fired, even if its in-between
Yeah bindable events can achieve the same thing as the code above. However, custom signals are generally better because they use less threads and don’t clone the arguments passed to the Fire method.
You can also use a function.
-- sending a negative value would reduce kills
-- sending a positive value would increase kills
local function setKills(value: number)
-- use assertions to keep the function robust
kills += value
local fn = arr[value]
if fn then fn() end;
end
Custom signals is an implementation of the BindableEvent Instance but with code, which in return gives much better performance because it doesn’t have the nuances BindableEvents have in their implementation.
i looked a little bit into it, seems pretty interesting, though im not that advanced into scripting yet na dits a bit of a struggle for me to understand, but i have it saved, and ill look more into it when i can!
though it ahs given me the idea to use modules rather then bindable’s