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: Attack scripts help

Previous Thread :: Next Thread 
bretty167 is not online. bretty167
Joined: 14 Nov 2008
Total Posts: 245
08 Sep 2011 11:10 AM
I have this script, that I made (Took a while to find the right bits, as I am a beginner at this), which is desgined to Attack the nearest torso, Could anyone change this script for me, so that it only attacks Players?

function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 60
local temp = nil
human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:findFirstChild("Torso")
human = temp2:findFirstChild("Humanoid")
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then

if game.Players:findFirstChild(human.Parent.Name) ~= nil then

if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end

if game.Players:findFirstChild(human.Parent.Name) == nil then

if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end



end
end
end

return torso
end
Report Abuse
rangersmash is not online. rangersmash
Joined: 18 Nov 2009
Total Posts: 2891
08 Sep 2011 11:14 AM
[ Content Deleted ]
Report Abuse
bretty167 is not online. bretty167
Joined: 14 Nov 2008
Total Posts: 245
08 Sep 2011 11:16 AM
It's not a request, I was asking if anyone could help me change a script so that it does somthing slightly different, A request is when someone asks you t make something COMPLETELY.
Report Abuse
Fl0xData is not online. Fl0xData
Joined: 01 Aug 2011
Total Posts: 18
08 Sep 2011 11:21 AM
No.
You request us to change the script to something you didn't even attempt to try.
Thats;
Lazy
Racist
(and) Slavery.
Report Abuse
bretty167 is not online. bretty167
Joined: 14 Nov 2008
Total Posts: 245
08 Sep 2011 11:28 AM
I'm going to ignore you fl0x, Because all you've really done on this forum Is rip off other people on mistakes.
Anyway, Is it possible to do Findnearestplayer()?, Or Just Torso?
Report Abuse
bretty167 is not online. bretty167
Joined: 14 Nov 2008
Total Posts: 245
08 Sep 2011 11:30 AM
I beleive I have fixed it, (Unless it still attacks other AI's, which I have not yet tested)

function findNearestPlayer(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 60
local temp = nil
human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:findFirstChild("Torso")
human = temp2:findFirstChild("Humanoid")
if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then

Report Abuse
bretty167 is not online. bretty167
Joined: 14 Nov 2008
Total Posts: 245
08 Sep 2011 11:39 AM
Nope... They still attack each other... Can anyone tell me How the local list=
could be changed so that it doesn't find an AI?
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