Managing different states for a player

I am making a magic game, and I’m trying to figure out how I would manage different states a player would be in during a combat. I don’t want a whole script just some guidance

My problem is I am not sure how I would go about handling states as casting, attacking, stunning etc. I am also planning on adding clashing so I would need other players to check what the enemy state is. If anyone could help me I would really appreciate it.

If you something is unclear please ask about it.

2 Likes

You could probably use boolValues for each state, though I believe there is a more efficient way to do this.

1 Like

You should store a table of values, but that can only get accessed only in that script.
If you want it accessed everywhere, I’d use BoolValues.

Option A:

local states = {
    StateA = true,
    StateB = false,
    StateC = false
}

Option B:

game.Players.PlayerAdded:Connect(function(player)
    
    local playerData = Instance.new("Folder", player)
    playerData.Name = "PlayerData"
    
    local state1 = Instance.new("BoolValue", playerData)
    state1.Name = "State1"
    state1.Value = false
    
    --Add more states if you want.
    
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.