|
| 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 |
|
|
| |
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
| |
|
|
| 07 Jun 2015 09:26 PM |
| put getclosest before the while true do |
|
|
| Report Abuse |
|
|
|
| 07 Jun 2015 09:28 PM |
| I did that and it still doesn't work. |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 07 Jun 2015 09:31 PM |
| quite obvious what your error is. |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 07 Jun 2015 09:32 PM |
| getclosest can't be found for some reason. |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| Joined: 14 Jun 2014 |
| Total Posts: 959 |
|
|
| 07 Jun 2015 09:33 PM |
| that funtion will never be called either |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 07 Jun 2015 09:38 PM |
| I tried nick's fix and it still didn't work. Same error. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 07 Jun 2015 09:46 PM |
| Oh wow I can't post the script at all, |
|
|
| Report Abuse |
|
|
|
| 07 Jun 2015 09:52 PM |
My script: http://www.roblox.com/SCP-173-item?id=256842813 |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 07 Jun 2015 10:30 PM |
| It's an infinite loop but it works properly. I can read it. |
|
|
| Report Abuse |
|
|