I’m looking to make a system where you walk up to an NPC and commences a turn-based battle, but I’m having trouble with understanding how I’m able to do this. Can anyone lead me in a proper direction? I feel like I’m not doing it correctly, at all.
What do you mean a turn-based battle? Do you mean that they turn toward you and attack?
No… Like Wizard101, Toontown, or pokemon.
Have some kind of server script that keeps track of whose turn it is. When its a player’s turn they can send what their “attack” or “move” is going to be to the server via a remote event.
When the event is fired have the server validate that it’s the player’s turn and if it is then complete the action they wanted to use for their turn.
Have the server change to the next player’s turn and repeat
How will I be able to have each script know who’s turn it is?
When the game starts have it choose a random player to start first.
Then after that player finishes their turn by completing some kind of action or by a timer running out you just switch to the next player in the list
You’ll also have to make checks for when players leave the game. You don’t want the game to break because someone left on their turn.
tables would be really important here, what I would do is use a proximity prompt, or magnitude:
local inbattle = {}
local NPC = script.Parent
ProximityPrompt.Triggered:Connect(function(player)
table.insert(inbattle,1,player)--i forgot the order lol
table.insert(inbattle,2,NPC)
--start battle
end)
the number position of the table is important, in this script, the player would start first
Yes. So would I use a .Touched event to initiate the battle with the NPC?
May I add you on discord because Ill have a lot of questions lol.