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: Need NPCs to replicate to each client

Previous Thread :: Next Thread 
SimpleSet is online. SimpleSet
Joined: 25 Feb 2017
Total Posts: 165
17 Aug 2017 05:58 PM
So I need NPCs to replicate to each client only, so their NPCs and what they are doing are only visible to that specific client. I tried making it parent to CurrentCamera when you interact with the NPC, but it does not work (and yes, it was in a local script). I know I can put them into ReplicatedStorage and spawn them into the workspace to do it, but would that increase it's ability to be hacked since it is on the client side? Please post if you can help.


#YoungDev
Report Abuse
SimpleSet is online. SimpleSet
Joined: 25 Feb 2017
Total Posts: 165
17 Aug 2017 06:07 PM
I understand, you guys don't know where the reply button is, Lemme help you out.
|
|
|
V


#YoungDev
Report Abuse
NexanianStudios is online. NexanianStudios
Joined: 16 Jul 2016
Total Posts: 1109
17 Aug 2017 06:09 PM
for i,v in pairs(game.Players:GetChildren()) do

local replicateEvent = game:GetService("ReplicatedStorage"):WaitForChild("ReplicateEvent")

replicateEvent:InvokeClient(v,NPCINFO)

end
Report Abuse
SimpleSet is online. SimpleSet
Joined: 25 Feb 2017
Total Posts: 165
17 Aug 2017 06:11 PM
This may be sad considering I've been using Lua for a long time, but uh, I don't use I,v in pairs much, so can you explain it... please?


#YoungDev
Report Abuse
NexanianStudios is online. NexanianStudios
Joined: 16 Jul 2016
Total Posts: 1109
17 Aug 2017 06:12 PM
The two variables i and v represent the following things:

I: The index of the table given in the pairs() function ex table[i]

V: The indexed value. ex v = table[i]
Report Abuse
Ezuras is online. Ezuras
Joined: 07 Nov 2012
Total Posts: 8768
17 Aug 2017 06:13 PM
i,v is basically a "pair" of data.

i represents the position (integer) of the value, and v represents the value

in this case, game.Players:GetChildren() will return the following:

[1] Player1
[2] Player2

and so forth

Report Abuse
BJCarpenter is online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
17 Aug 2017 06:14 PM
With FE On, anything that I Clone in a Local Script in StarterPack, and Parent to the Camera, is only visible to that Player.
Report Abuse
NexanianStudios is online. NexanianStudios
Joined: 16 Jul 2016
Total Posts: 1109
17 Aug 2017 06:14 PM
so you just put a table to be run through in pairs().

if you did print(i) in the function it would do this

1
2
3
4


if there were four items in the table
Report Abuse
SimpleSet is online. SimpleSet
Joined: 25 Feb 2017
Total Posts: 165
17 Aug 2017 06:29 PM
for i,v in pairs(game.Players:GetChildren()) do

local replicateEvent = game:GetService("ReplicatedStorage"):WaitForChild("ReplicateEvent")

replicateEvent:InvokeClient(v,NPCINFO)

end

--In this script, you are sending the info to a localscript from a serverscript. the problem with this is I have the NPCs in serverstorage to help prevent hackers from getting to them, so I don't think I can do that unless it still counts the NPCs being in the parameter.


#YoungDev
Report Abuse
NexanianStudios is online. NexanianStudios
Joined: 16 Jul 2016
Total Posts: 1109
17 Aug 2017 06:33 PM
NPCINFO was just a placeholder, you can put whatever you want in its place, including the directory of the NPC
Report Abuse
SimpleSet is online. SimpleSet
Joined: 25 Feb 2017
Total Posts: 165
17 Aug 2017 06:33 PM
Thaaaaaaaaanks guys, bump


#YoungDev
Report Abuse
SimpleSet is online. SimpleSet
Joined: 25 Feb 2017
Total Posts: 165
17 Aug 2017 06:35 PM
The problem is that local scripts can't go into ServerStorage, which is where the NPCs are, and I do not know if I should put them into replicatedstorage because I dont know if they are easier to hack in there.


#YoungDev
Report Abuse
NexanianStudios is online. NexanianStudios
Joined: 16 Jul 2016
Total Posts: 1109
17 Aug 2017 06:37 PM
You don't have to access it from a local script, the script should be a server script, and the npc object should be passed on into a localscript through the event
Report Abuse
SimpleSet is online. SimpleSet
Joined: 25 Feb 2017
Total Posts: 165
17 Aug 2017 06:38 PM
Hm... that sounds good now that I hear it. I'll test it out and tell you if it works.


#YoungDev
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
17 Aug 2017 06:40 PM
I found have the server control all of the AI it has a delay issue with replication whilst having them control themselves there is no delay, but its really up to you.
Report Abuse
WatermelonMan4676 is not online. WatermelonMan4676
Joined: 20 Jan 2014
Total Posts: 5516
17 Aug 2017 06:41 PM
"This may be sad considering I've been using Lua for a long time, but uh, I don't use I,v in pairs much, so can you explain it... please?"


lold
Report Abuse
SimpleSet is online. SimpleSet
Joined: 25 Feb 2017
Total Posts: 165
17 Aug 2017 07:14 PM
That script does not work, it transfer npc as nil because local scripts, yet again, cannot access serverstorage.


#YoungDev
Report Abuse
NexanianStudios is online. NexanianStudios
Joined: 16 Jul 2016
Total Posts: 1109
17 Aug 2017 07:52 PM
hmm.. Is npc an object? what does it do?
Report Abuse
Cyrakohl is not online. Cyrakohl
Joined: 09 Nov 2014
Total Posts: 3197
17 Aug 2017 08:09 PM
################ This will replicate to every client.
Report Abuse
SimpleSet is online. SimpleSet
Joined: 25 Feb 2017
Total Posts: 165
18 Aug 2017 06:16 PM
I know replicatedstorage replicates to all clients, hence its name! But is there a better way to make it a bit harder to hack?


#YoungDev
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
18 Aug 2017 09:17 PM
Modules in server storage ;)
Report Abuse
SimpleSet is online. SimpleSet
Joined: 25 Feb 2017
Total Posts: 165
20 Aug 2017 02:34 PM
Scripts do not function in serverstorage. By the way, I just put 'em in replicatedstorage, Ill just make anti-hack scripts.


#NewDev
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
20 Aug 2017 04:26 PM
I said modules, they function in server storage silly.
Report Abuse
SimpleSet is online. SimpleSet
Joined: 25 Feb 2017
Total Posts: 165
23 Aug 2017 06:17 PM
You clearly do not understand. the client cannot get ANYTHING in serverstorage because anything in it is nil to the client, making impossible for the client to get something from it.


#NewDev
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
23 Aug 2017 09:47 PM
Why are you doing this on the client, please explain to me why on earth your doing this.
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