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 » Scripters
Home Search
 

Re: Bug with Humanoid's script

Previous Thread :: Next Thread 
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 08:32 PM
-- Made by BFFstick00
inview = false
while wait(0.1) do
while inview do
inview = game.Workspace.Camera:WorldToScreenPoint(script.Parent.Position)
script.Parent.Parent.Humanoid:Move(getclosest(script.Parent.Position))
wait(0.1)
end
end
function getclosest(position)
local closest = math.huge()
local player = nil
for i, v in pairs(game.Players:GetChildren()) do
if closest < v:DistanceFromCharacter(position) then
closest = v:DistanceFromCharacter(position)
player = v
end
end
return player
end

it is supposed to find the closest player and chase them if it is not being watched.
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 08:53 PM
Bump ;-;
Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
07 Jun 2015 08:57 PM
This one was just too easy.

"inview = false
...
while inview do"

translates to

"while false do"

which translates to

"while (false == true) do"

false will never equal true.

you will never chase anyone.
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 09:06 PM
DOH! I will try that.
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 09:11 PM
New error, new script:
22:09:36.030 - Workspace.SCP-173.Torso.SCP173:6: attempt to call global 'getclosest' (a nil value)

-- Made by BFFstick00
inview = true
while wait(0.1) do
while inview do
inview = game.Workspace.Camera:WorldToScreenPoint(script.Parent.Position)
script.Parent.Parent.Humanoid:Move(getclosest(script.Parent.Position))
wait(0.1)
end
inview = game.Workspace.Camera:WorldToScreenPoint(script.Parent.Position)
end
function getclosest(position)
local closest = math.huge()
local player = nil
for i, v in pairs(game.Players:GetChildren()) do
if closest < v:DistanceFromCharacter(position) then
closest = v:DistanceFromCharacter(position)
player = v
end
end
return player.Character.Torso.Position
end
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 09:26 PM
Bump ;-;
Report Abuse
LegitimatlyMe is not online. LegitimatlyMe
Joined: 30 Oct 2013
Total Posts: 1108
07 Jun 2015 09:26 PM
put getclosest before the while true do
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 09:28 PM
I did that and it still doesn't work.
Report Abuse
LegitimatlyMe is not online. LegitimatlyMe
Joined: 30 Oct 2013
Total Posts: 1108
07 Jun 2015 09:29 PM
output?
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 09:30 PM
22:28:06.481 - Humanoid is not a valid member of Workspace
22:28:06.483 - Script 'Workspace.SCP-173.Kill', Line 7 - global onTouch
22:28:06.487 - Script 'Workspace.SCP-173.Kill', Line 3
22:28:06.489 - Stack End
Report Abuse
LegitimatlyMe is not online. LegitimatlyMe
Joined: 30 Oct 2013
Total Posts: 1108
07 Jun 2015 09:31 PM
quite obvious what your error is.
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 09:31 PM
Ho wait wrong script.
22:31:23.735 - Workspace.SCP-173.Torso.SCP173:6: attempt to call global 'getclosest' (a nil value)
22:31:23.737 - Stack Begin
22:31:23.739 - Script 'Workspace.SCP-173.Torso.SCP173', Line 6
22:31:23.740 - Stack End
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
07 Jun 2015 09:31 PM
That loop at the top will never stop. You have to tell while loops when to stop from inside the loop.

I didn't read enough to know if that's your problem, it's just the first thing I noticed.
Report Abuse
LegitimatlyMe is not online. LegitimatlyMe
Joined: 30 Oct 2013
Total Posts: 1108
07 Jun 2015 09:32 PM
getclosest can't be found for some reason.
Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
07 Jun 2015 09:33 PM
"script.Parent.Parent.Humanoid"

you should check the existance of Humanoid in script.Parent before running code that assumes its existance.
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
07 Jun 2015 09:33 PM
that funtion will never be called either
Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
07 Jun 2015 09:34 PM
Also, your function you use in the loop comes after the thread enters a loop, so you need to put the function before the loop.
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 09:35 PM
@nick It's in the model I have made of course it exists and why script.Parent when the script is in the Torso.
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 09:38 PM
I tried nick's fix and it still didn't work. Same error.
Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
07 Jun 2015 09:38 PM
You still cannot assume existance of anything.

Make sure you if model:FindFirstChild("Humanoid") then before you model.Humanoid.Properties = blah.
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 09:44 PM
22:41:44.414 - Workspace.SCP-173.Torso.SCP173:15: attempt to index local 'player' (a nil value)
22:41:44.416 - Stack Begin
22:41:44.418 - Script 'Workspace.SCP-173.Torso.SCP173', Line 15
22:41:44.419 - Stack End

I can't post my script in the same reply due to "profanity".
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 09:46 PM
Oh wow I can't post the script at all,
Report Abuse
BFFstick00 is not online. BFFstick00
Joined: 25 Oct 2010
Total Posts: 800
07 Jun 2015 09:52 PM
My script:
http://www.roblox.com/SCP-173-item?id=256842813
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
07 Jun 2015 10:25 PM
You have a profane, potentially infinite loop that stops the script dead in its tracks:P
Report Abuse
nickcool9999 is not online. nickcool9999
Joined: 04 Dec 2007
Total Posts: 1528
07 Jun 2015 10:30 PM
It's an infinite loop but it works properly. I can read it.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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