Help Creating a Status-Effect(s) System

Hello, I want to create a system that would inflict status effects like poison, bleeding, etc. I don’t know where to start to make a system like this nor would I know how to make it optimized either. Any help with starting this will help.

For more information, I want to create something like what Minecraft has: Example Here

Thanks for your time!

1 Like

I could help you by saying what I used to make status effects.

I made preexisting NumberValue instances which are the status effects. There will be attacks that increase the .Value property of the NumberValue status effect instance. Then there’s code that will run if the value property is above 0.

This works for status effects that can’t stack up their time. For example, if you’re hit by 2 attacks that inflict 5s of bleed at the same time, they won’t be 10s.

1 Like

I’m sorry, but I’m confused on this

Would I make a table with something like this, and make a loop whenever a NumberValue instance is added to the player?

local Loops = {} --Holds the loop 
local StatusEffects = {
	
	[1] = function(...) --Poison
		
	end,
	
	[2] = function(...) --Bleeding
		
	end,
	
}

I made preexisting number value instances parented to the player, which are named the statuseffects.

The code in the attacks that apply them will simply just increase the number inside the numbervalue statuseffects instances.

There’s then separate code that handles what the effects actually do.

My code for example

(statuseffect module script)

The attacks will then call the modulescript and run that function.

(preexisting instance in a script called Setups)
image

local Amount = 0
while Amount < 10 do --loops 10 times
    Amount += 1
    Character.Humanoid:TakeDamage(1)
    wait(1)
end