Help making Turn-Based system

I want to make a simple turn based system with the ability to have multiple players and NPCs.

I’m not sure how to go about this though.
I’m assuming module scripts would help here, but I’m not quite sure how to properly use them for this.

How would I make a system where only one player/NPC can do actions at a time? (Actions would be tied to UI buttons)

2 Likes

What did you mean? If you mean you want to make a story-based system, just make a few Module Scripts that have the main logic of participants (actors, players and npcs) and dialogue system, then just make a main Script in ServerScriptStorage that controls everything. Just watch some videos on YouTube on how to make that type of games.

1 Like

Sorry, I should’ve specified.

I meant a combat system.
Think sort of like darkest dungeon.

1 Like

Okay, look, you do an array where is all the players and npcs, or just participants. then you can use table.sort to sort everyone like the order. you make a variable which tracks current participant who acts right now, like this

local curTurn = 1

also you disable ui for players who not in turn right now, for example by calling remote event to all clients who is not the player who has his turn right now

then you do main logic

if participants[currentTurn] == player then
    enableUI(player)
else
    doNPCStuff(participants[currentTurn])
end

also you do the loop back

currentTurn = currentTurn + 1
if currentTurn > #participants then
    currentTurn = 1
end

sorry for bad explanation, my first post on forum

1 Like

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