Hi, am asking for a method on how to create a terminal system, I have used four methods that have all failed.
Method A I used a .Touched event on the terminal and then would detect if the touching part was a player, if it was there would be a loop that :GetTouchingParts() of terminal and would break if the player that was touching the terminal stopped touching the terminal, this didn't work because in order to use the :GetTouchingParts() function the parts cannot have NoCollide set to false, bot a players legs and the terminal did, and if the terminal is then there is no way for the terminal to touch the other parts of the body.
Method B I obviously didn't learn my lesson, I had a while true do loop that would :GetTouchingParts() of the terminal, if there were players then uses logic to figure out which team they're on and yeah, at the end of the loop would add points and what not, but didn't work because I couldn't use the :GetTouchingParts() function with this scenario
Method C I used a .Touched event on the terminal that would detect if the touching part was a player if it was then a .touchended function would be made and would only make the capturing value false if the .touchended was the part the .touched event found, this didnt work because the .touchended events would stack and would cause a lot of lag
Finally, Method D I used a .Touched event on the terminal that would detech if the touch part was a player, and would add that player to a table, then I used a .touchended event to find if the part was a player, they would remove it from the table, finally a while true do loop would use these tables to add points and do logic for every second, this didn't work because of just a lot of errors and poor execution, but it would seem that using this way requires a lot to prevent errors, because players have 2 legs and every time those legs move it fires a .touched event for both, this can be stopped using for loops and if statements, but by then the whole thing is too buggy, and becomes very unsophisticated
I know that must of been very sloppy writing, but when you try to explain scripting while also using English grammar it gets mixed up, also it seems like every self-taught scripter has their own style, and this might make it hard for other scripters to understand one's, 'Style' but I'm just asking for a working method that can be easily explained and works flawlessly, I partly blame this on Roblox and their :GetTouchingParts() function not working with parts that have a Collide value of false. Maybe I'm just overcomplicating this, but I'm also protesting because I'm a little upset over this and I cannot find a way around it :/. Sorry.
Methods:
(humanoidRootPart.Position - targetSpotCenter).Magnitude <= radius
will tell if you they're close enough to "count".Based on your descriptions, I am wondering if you are using tables to their full potential. By using players (or other things) as keys, you can have instant lookup as to whether a player is in a table or not. ex, if you have a list of parts, you can do this:
-- say 'parts' is a list of parts local players = {} -- the key will be a player, the value will be true. It will hold all the players that have at least 1 part in 'parts' for i = 1, #parts do local player = game.Players:PlayerFromCharacter(parts[i].Parent) if player then players[player] = true end -- store that 'player' is in the list of parts end -- Now you can do something for each player local teamStrength = {} for player, _ in pairs(players) do teamStrength[players.Team] = (teamStrength[players.Team] or 0) + 1 -- The "or 0" means "use 0 if no value is available" end for team, strength in pairs(teamStrength) do print(team, "has strength", strength) end
Out of the methods you described, I think Method D sounds like you were close. If you need further help, consider posting the code to your Method D and letting me know in a comment to this answer (so I will be notified) and I can take a look at it.