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 » Game Creation and Development » Scripting Helpers
Home Search
 

Re: THE lamest glitch ever in a script - WHY IS THIS HAPPENING?!

Previous Thread :: Next Thread 
BogyMac is not online. BogyMac
Joined: 04 Nov 2011
Total Posts: 823
15 May 2014 12:20 PM
playerList = {"Player1","Player2"}

script.Parent.Touched:connect(function(hit)
for i = 1, #playerList do
if hit.Parent.Name ~= playerList[i] then
print(hit.Parent.Name.."'s Name is not equal to list of Admins")
h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil then
h:TakeDamage(1)
end
end
end
end
end)

Okay, with this script, if I were to touch the brick, it shouldn't hurt me.... BUT IT DOES. EVEN THOUGH MY NAME IS PLAYER1 IN STUDIO!

What the heck is going on here?
Report Abuse
DataStore is not online. DataStore
Joined: 07 Feb 2012
Total Posts: 8540
15 May 2014 12:38 PM
Currently, you're iterating through the table "asking" if the hit parent's name is equal to the current iteration. So, whilst your name may match "Player1" it doesn't match "Player2", which causes it to damage you.

Report Abuse
BogyMac is not online. BogyMac
Joined: 04 Nov 2011
Total Posts: 823
15 May 2014 12:40 PM
I see. Thanks for the tip, I'll see what I can do.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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