generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Roblox » Help (Technical Support and Account Issues)
Home Search
 

A scripting problem (not too basic)

Previous Thread :: Next Thread 
kent911t is not online. kent911t
Joined: 06 Jul 2011
Total Posts: 18
06 Apr 2017 06:32 PM
My objective is to get everything in the workspace, compare it to every player's name and if it doesn't match any of them output the name of the object.

this code will work if there is only 1 player in the server:

for _, v in pairs(game.Players:GetChildren()) do
for _, v2 in pairs (workspace:GetChildren()) do
if v2:FindFirstChild("Humanoid") then
if v2.Name ~= v.Name then
print(v.Name)
end
end
end
end

however if there are 2 or more then it will take 1 name and try comparing it to 2 characters in the workspace, which will output 1 player's name

i don't want this happening

any help?


aaaaaaaaaaaaaaaaaaaaahhhh
Report Abuse
end_itt is online. end_itt
Joined: 27 Aug 2011
Total Posts: 70
06 Apr 2017 06:36 PM
you could just target players in Players then do Player.Character might work idk ####
Report Abuse
LoyaltyLeader is not online. LoyaltyLeader
Joined: 06 May 2012
Total Posts: 409
06 Apr 2017 06:52 PM
function compareObjectsinWorkspace()
local players = game:GetService("Players"):GetPlayers() -- Get the players in-game
local playerlist = table.concat(players, ", ") -- Create a list of everyone
print("Players: "..playerlist)
for _,obj in pairs(workspace:GetChildren()) do -- Find all objects in workspace
if string.find(playerlist:lower(), obj.Name:lower()) then -- If the objects name is found in the player list, print the object name
print("Object found: "..obj.Name)
end
end
end


Came up with this on the spot, may need tweaking but otherwise, I think it suits your need.

What it does is create a single string containing the names of everyone in the server. If an object in the workspace does not have their name inside this string, print the objects name. You should note this checks for every player simultaneously, not one at a time.


Report Abuse
kent911t is not online. kent911t
Joined: 06 Jul 2011
Total Posts: 18
06 Apr 2017 07:15 PM
thanks, never knew about the table.concat function


aaaaaaaaaaaaaaaaaaaaahhhh
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Roblox » Help (Technical Support and Account Issues)
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image