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: Broken NPC - Server Only

Previous Thread :: Next Thread 
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
07 Nov 2014 02:14 PM
id=185900980

Can anyone identify and fix the problem??

It moves and follows you if ur close enough, but for me, it didn't follow me. It just kept going in a streight line and fell off the baseplate. What the heck? ;_;
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
07 Nov 2014 02:17 PM
Bahmp
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
07 Nov 2014 02:19 PM
Im on my phone so I can't test it

Explain the problem better
Like besides the fact if walks off the base

What do you mean server only
What do you mean only if your close, it works if you are close?
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
07 Nov 2014 02:22 PM
local CurrentPart = nil
local MaxInc = 14

function onTouched(hit)
if hit.Parent == nil then
return
end

local humanoid = hit.Parent:findFirstChild("Monster")

if humanoid == nil then
CurrentPart = hit
end
end

function waitForChild(parent, childName)
local child = parent:findFirstChild(childName)

if child then
return child
end

while true do
print(childName)

child = parent.ChildAdded:wait()

if child.Name==childName then
return child
end
end
end

local Figure = script.Parent
local Humanoid = waitForChild(Figure, "Monster")
local Torso = waitForChild(Figure, "Torso")
local Left = waitForChild(Figure, "Left Leg")
local Right = waitForChild(Figure, "Right Leg")

Humanoid.Jump = true

Left.Touched:connect(onTouched)
Right.Touched:connect(onTouched)

while true do
wait(math.random(2, 6))

if CurrentPart ~= nil then
if script.Parent.Chasing.Value == false then

Humanoid:MoveTo(Torso.Position + Vector3.new(math.random(-MaxInc, MaxInc), 0, math.random(-MaxInc, MaxInc)), CurrentPart)
end
end
end




This is the script that's causing the problem I believe. When he walks towards me, and then he moves randomly again (The chasing bool should have fixed this though :/) he sometimes gets glitched and moves in a streight line forever unless he randomly moves again. He also doesn't follow me while moving in the streight line.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
07 Nov 2014 02:29 PM
:MoveTo(Torso.Position

That should be currentPart.Position

Otherwise you are moving the the npcs current position + some random numbers
Report Abuse
HyroadCoder is not online. HyroadCoder
Joined: 15 Jul 2014
Total Posts: 813
07 Nov 2014 02:32 PM
I changed that and this time he moved far far away. Not just little footsteps.

;-;
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
07 Nov 2014 02:36 PM
Did you move?

You never update the path so he just goes straight for you/where you were
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