I need to load and unload only NPCs, they are really expensive to run all the time, I need to know how to remove it on client-side so it will be less expensive
What do you mean by âexpensiveâ? Do you mean memory-consuming?
I honestly have no idea to do this, just wondering what you meant. Hope you get help from a professional!
yes
30 charsssssssâŚ
bump, still need help thanks reee
bump, still need help thanks again
Well , I donât think it is complicated. I might have an idea.
In your local script , fire a server event (assume you have created a remote event) like so;-
local Event = game.ReplicatedStorage.MyEvent
Event:FireServer()
In a server script , create a connection function for that event;-
game.ReplicatedStorage.MyEvent.OnServerEvent:connect(function(Player)
game.ReplicatedStorage.MyEvent:FireAllClients(s)
end)
So basically , you are telling the server to tell all the client to do the same thing (this will save memory for server because server doesnât need to render the humanoid/npc)
Finally , in the previous local script . Create a connection function for that event .
game.ReplicatedStorage.MyEvent.OnClientEvent:connect(function()
local NPC = game.ReplicatedFirst.MyNPC:Clone()
NPC.Parent = workspace
----------// do like CFrame position and all that stuff for the NPC.
end)
This way , The server doesnât render anything at all. Only you and all the other player can see it.
There is a downside though , player that have âhacking capabilitiesâ can fire that event at will . So I might suggest you put some security on that.
By the way , I did not test the code I write above. There might be typos.
What they most likely do is detect whenever the clients enter a restaurant and then render them locally, and when they player is not in that restaurant they parent the npcs to ReplicatedStorage. All the npc animations are most likely done from the client, and maybe they do the moving on the server, but they might do everything on the client.