How to make a killer bot - lua

I'm actually new to roblox studio and I want to make my own basic shooter game. I know when I publish only one or two will come at the beginning and I don't want them to leave without playing itself. So I decided to create killer bots who play just like players[kill the players, and escape from not getting killed]. Is there any way I can do that because NPC creating is easy but asking them to kill the players is difficult and moreover the NPC's are not counted as players and not shown in the leaderstats. How can I show that?

Using PathFinding won't work that well, so I recommend using a Raycast and Strafing. And if the npc touches player, check if the hit part's parent IS a player and then set its health to 0 or damage his health.
For leaderstats, the roblox sword has a tag called "creator" that is there for KOs. Add the creator tag for the leaderstats to work.

Related

Why is my teleporting not working? (Roblox)

so in my game, I made another place in the asset manager. For some reason I cant teleport to it. It says teleport failed and in the console it says the place is not published. The game is published. And I dont think you have to publish places. I am using ReserveServer and TeleportToPrivateServer. I have tried to figure it out and my game IS published. Any help appreciated!
Have you tried testing it in an actual game setting instead of just roblox studio? Also make sure both games are public.
I would suggest using the TeleportService:Teleport function, rather than TeleportAsync, if you need to teleport to a private server, I'd suggest just not using Async, as async teleport functions have had b
Here's a usage case:
game:GetService("TeleportService"):Teleport(123456, game.Players:GetPlayers()[1])
Arguments being place id, player. In TeleportToPrivateServer, which you would need if you're specifically teleporting to a private server (which you stated you were using, the usage case is
game:GetService("TeleportService"):TeleportToPrivateServer(placeID,code,player)
You likely already know this, but if you were missing something, or using the wrong variables, it could be a fix.
If that doesn't solve your problem, make sure:
In Game Settings > Security Third Party Teleports are enabled
Your referenced player variable, or place id aren't nil
And make sure the place has been published
Keep in mind, you can't teleport in Roblox Studio, so you should know it works if you get an error in the console stating you may not teleport in the roblox studio.

User Input Service's Input Began not firing

I am working with User Input Service to make a snake game within Roblox, and the event, Input Began, is not firing. I even copied code from the official Roblox website to teach how to script, and nothing happened. What could be going wrong?
UserInputService only works in LocalScripts, and according to the docs :
A LocalScript will only run Lua code if it is a descendant of one of the following objects:
A Player’s Backpack, such as a child of a Tool
A Player’s character model
A Player’s PlayerGui
A Player’s PlayerScripts.
The ReplicatedFirst service
Double check that your LocalScript is in one of those locations and that it is not Disabled.

Lance GG : Is it posible to activate game pause?

Is it possible to add pause function to the game.
Without setting all DynamicObject velocity to 0. E.g. the pong game.
Lance is a multiplayer game engine, so it wouldn't make sense to pause the game just for a single client - as the game must continue for all other players.
Nevertheless, there is an ignorePhysics attribute on the GameEngine class. Setting this attribute to true on the server would stop the physics, and should work in interpolation mode.
To some extent, it would make sense with a global pause feature. Think any modern MOBA - if a client disconnects, the game is paused to wait for a reconnect. Unless of course, Lance.gg is only meant for persistent worlds :)

Player swipe to remove match

Let's say I have a turn based match with two players. At some point player 1 recognizes that he is about to lose the game. When it is Player 1's turn, he uses Game Center App to do a swipe to remove the match.
Issues:
A. Take turn timer never expires on Player 1. So the match's turn will not switch to Player 2 when the time expired.
B. The game also offers a view only mode so players can view the game progress while he is out of turn. But since no status was updated to indicate that Player 1 had removed the match manually. App can offers no resolution. Also, you can only end match while it is your turn.
Ideally, I want to declare Player 2 as a winner and end the match.
How do you handle in this situation?
I finally found a workaround for this.
If you delete a match, then call GKTurnBasedMatch:loadMatchesWithCompletionHandler, the deleted match doesn't appear (as expected). However, it turns out that you can still re-download the deleted match using GKTurnBasedMatch:LoadMatchWithID, if you happen to still have the deleted match's ID.
I think we can reasonably assume that The Cheater is going to play the game again; otherwise, why would they care about incurring a loss? Therefore, I implemented the following:
Maintain a table locally, on the device, of matches.
On startup, pull the list of local player's matches from Game Center and compare against my local list.
When The Cheater recognizes the situation and deletes the match using the Game Center interface, the match is removed from Game Center, but not from my local DB. When The Cheater starts my game again, I see that they have more matches locally than on Game Center.
I then call either participantQuitInTurnWithOutcome or participantQuitOutOfTurnWithOutcome, as appropriate, with an outcome of GKTurnBasedMatchOutcomeLost.
This passes the turn to the next player and records a loss for The Cheater. It won't work if the cheater never plays the game again, though. (But, if they're not playing, they're not wrecking any more matches, so the chaos is contained)

Where does game logic go in Rails apps?

(Disclosure: I'm very new to Rails)
I am trying to make a RISK-style board-game in Rails, though this question may apply for any MVC-style framework.
I have players and games. Players can join games until the game is full. Trying to join a full game (or the same game twice) signals an error, yada yada.
Below are three pieces of game logic that I am unsure where to place, or at least where they are typically placed.
If a game is full, it should start and do things related to that (ie, messaging all players that the game has begun, randomly disperse armies across the map).
When a player executes moves during his turn it seems reasonable to have that logic in the controller. What about when his turn ends and it is time to message the next player? Would that code go in the same controller as
Suppose that a player forfeits his turn if he does not finish it within 24 hours. I'd need to periodically look at all the games in my app and see if a player started a turn more than 24 hours ago. Where would this logic go?
My question is: Where does logic for items like the above go in a Rails/MVC app?
In one sense I could stuff all of it except 3. into the controllers for the last-done-action. For instance I could place the logic for 1. in the player-joins-game controller method (check if the game is full after every player join, if it is, commence 1. related logic). This seems like it might be the wrong place, but maybe that's how it is typically done.
Rails' convention is "fat model, thin controller". so I would suggest that the state of the game should be held by the Game model.
You webapp consists of zero or more games, and each game consists of 1 or more players.
The state of "full", or the state of "game begun" are properties of the game, and should be held by that model.
So for 1) When the final player joins (or perhaps, all current players vote to start the game), the game state (a property of Game) would be set to "begun", the property that holds the currently active player would be set, and a delayed job would be queued to message all the players.
For 2, the game has a "execute move" method in the Game controller that would check that the player executing the move is the current player, then it would execute the move against the Game model. The Game model internally would know if the move is valid, what the result is, and what the next step(s) would be. It would, again, use something like a delayed job to message the next player.
For #3, again, a delayed job could be set to execute the timeout. I'm not 100% on how to schedule delayed jobs, or if there's another gem/plugin that would work better. But, the job would call a method on the Game controller to check the status of the game at the required time. If the player has not moved, then execute your forfit logic, which would, again, be a method in the Game model.
The state of each player could be held in the Player model, or in the Game model, I suppose, depending on the game, and how much interaction between Player models there might be.
In the case of a risk game, I would think the player model would be rather thin, as the state of the board is more about which player owns a country, and how many armies they have there - that's more a state of the game, then a state of each individual player. I would expect the Player model in a risk game to be more oriented towards metadata about the actual player - username, wins/losses, skill level, etc.
In a game like Supremacy, where the player has resources, nukes, etc., then there's more data to store in the Player model.

Resources