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
 

Making Local NPCs

Previous Thread :: Next Thread 
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 07:26 AM
So in order for them to work, you must make a local script in a descendant of the player to access their camera into the model and control them from there? Should I use GetChildren for this?
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 07:32 AM
Wow, people look but don't answer.
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
24 Mar 2013 07:34 AM
You could just put a simple local script in the startergui and have them all do the same thing, and boom does the exact same thing, and it's easier.
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 07:35 AM
Explain that in detail please? I don't get what you said.
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
24 Mar 2013 07:38 AM
Okay, when a player enters a game anything in there starter pack, and starter gui get cloned, depending on were you put it is were it ends up starter pack ends up in the player backpack, and starter gui ends up in the players gui. Well you said you needed to put a local script in a descendent of the player to access there camera, if you put the localscript into the starter gui you can clone a local script accessing there camera into the players gui.
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 07:41 AM
Scripts don't run in the camera.
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
24 Mar 2013 07:43 AM
Sorry, I am obviously not explaining good enough for you to understand what I am trying to get you to grasp, I will dumb this down as much as possible.

Put the script in the starter gui, then it will get cloned into every players PlayerGui when they enter, then code the local script to get the players camera and do whatever you wanted to do with it.
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 07:53 AM
Oh. That's what I basically said in the post. :L
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
24 Mar 2013 07:55 AM
Well, theirs obviously ways through scripts to do this, you could make the local script to access the players camera, and make it disabled, then use a normal script like this.

derp = game.Workspace.YourCameraLocalScript
game.Players.PlayerAdded:connect(function(p)
derp2 = derp:Clone()
derp2.Parent = WhateverDescendantOfThePlayerYouWant
end)
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 07:58 AM
I'm talking about NPCs, not players. Sorry if I said players in my posts.
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 07:58 AM
But why won't this work?:

local cam = workspace.CurrentCamera

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(char)
char:WaitForChild("Torso")
char.Parent = cam
end)
end)
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 08:00 AM
Change:

local cam = workspace.CurrentCamera

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(char)
repeat wait() until (char ~= nil)
char.Parent = cam
end)
end)
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 08:01 AM
It's in a local script.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
24 Mar 2013 08:04 AM
Examine the below LocalScript code:


repeat wait() until game.Players.LocalPlayer
player = game.Players.LocalPlayer
camera = game.Workspace.CurrentCamera

newClone = game.Lighting.NPC:Clone() -- You can access lighting locally, lol.
newClone.Parent = camera
-- Do what you want with the NPC.
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Mar 2013 08:05 AM
@Directory, I guess he already know how to do that.

But Mirror, please explain more in-depth. Should the NPCs be synchronized so they will all act the same, or should Player1 ex. see an NPC in a shop, while that NPC is on the roof of the shop on Player2's screen?

Because then we're going to have some kind of connection element in the Workspace or such, like a Humanoid in a Configuration :P Whenever it changes, the humanoid associated with that 'fake' Humanoid will do the same (except having 0 health xD).

So yeah, then you can manipulate local NPCs in that way.

Workspace
>Camera for Player1
>>NPC1
>>NPC2
>Camera for Player2
>>NPC1
>HumanoidFolder (Configuration)
>>NPC1 (Humanoid) <-- look, the humanoid have the same name as the NPC.
>HumanoidManagement (Script)

Players
>Player1
>>PlayerGui
>>>MyHumanoidManager (Script)
>Player2
>>PlayerGui
>>>MyHumanoidManager (Script

Doesn't it seem good? yirh!

- As, their cat was sitting right there!
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 08:05 AM
Bump.
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 08:10 AM
Now I can make a single player RPG that's multiplayer, but single player! YEAH!
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 08:11 AM
A problem with your script the destroyer:
It clones the NPC when I respawn.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
24 Mar 2013 08:13 AM
Just create a value in the player that has to be false for my code to run...
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 08:23 AM
This would work?:


repeat wait() until game.Players.LocalPlayer
player = game.Players.LocalPlayer
NPCs = game.Lighting:GetChildren()
bool = true
camera = game.Workspace.CurrentCamera

for i = 1, #NPCs do
if (bool == true) then
bool = false
newClone = NPCs[i]:Clone()
newClone.Parent = camera
else
print("Don't Clone The NPC.")
end
end
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 08:24 AM
nope
Report Abuse
MirroredEdge is not online. MirroredEdge
Joined: 14 Mar 2013
Total Posts: 98
24 Mar 2013 08:28 AM
Bump?
Report Abuse
nightmare3o is not online. nightmare3o
Joined: 21 Jun 2008
Total Posts: 956
24 Mar 2013 09:11 AM
Use a BoolValue. Everytime your script gets cloned the Bool is set to true again.
Report Abuse
As8D is not online. As8D
Joined: 24 Dec 2009
Total Posts: 2907
24 Mar 2013 09:29 AM
^ Or check whatever the camera already contain something.

if #workspace.CurrentCamera:GetChildren() > 0 then
print("Oh no, we have already inserted something into the camera!")
end


- As, font style mai ziggi pl0x.
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