Which Way Is Better To Make Stun System

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    i want to make Stun System

  2. What is the issue?
    I dont know which way is better to make

  3. What solutions have you tried so far?
    looking in devforum and found so much people making it by creating a new object inside folder and use FindFirstChild to check it

Which Should I Use For Stun System? Between “BoolValue” or “Create Object”

BoolValue Is Just a 1 BoolValue Object And Use :GetPropertyChangeSignal(“Value”) to check when the value getting changed

StunValue:GetPropertyChangedSignal("Value"):Connect(function()
       if StunValue.Value == true then
              print("Stun")
       else
              print("Stun End")
       end
end)

or Create Object Inside Folder And Use .ChildrenAdded/.ChildrenRemoved To Check

StunFolder.ChildrenAdded:Connect(function()
       print("Stun")
end)

StunFolder.ChildrenRemoved:Connect(function()
       if not StunFolder:FindFirstChild("Stun") then
              print("Stun End")
       end
end)

Your first snippet should use the Changed event/signal.

StunValue.Changed:Connect(function(Stun)
	if Stun then
		--Start stun.
	else
		--Stop stun.
	end
end)
2 Likes

Using a bool value for a stun system is not really efficient unless you’re ONLY checking if the player is stunned for other stuff, using instances and adding children is much more viable better flexible solution to implement to your fighting game as you can check if the player is stunned before removing the player’s stun, For example if you punch the player and then use a move the punch would deactivate the stun effect after a certain time whereas if you use the children method you can easily keep the effect.

example:

local FFC, WFC = game.FindFirstChild, game.WaitForChild
StunFolder.ChildrenAdded:Connect(function()
       -- stun the player
end)

StunFolder.ChildrenRemoved:Connect(function()
     if not FFC(folder, "Stun") then
           -- Remove the stun
     end
end)
1 Like