About a year or so ago, I created a script that would create local parts in a dialog choice as part of the character. I now here there is a way to force the ownership of parts to either the server or the client. How would I do this? And is there a way to make sure only the client can see the parts?
Yes - there is. It's FilteringEnabled. It's a property in workspace that you can enable. Check out the link for a good article on it.
Basically, changes you make on the client won't be replicated to the server. That means any parts you create on the client will only exist on that particular client.
Once you enabled it, all you need to do is create the part in a local script;
Instance.new("Part", workspace)
A local part can be created by putting the part into the player's Camera
object, located in Workspace
. Here is a quick and simple tutorial:
1. Set Up
The first thing to do is to insert an anchored 4x1x4 brick into ReplicatedStorage
. Next, you need to add a LocalScript
into StarterGui
. Now you have a brick to copy and a script to copy it.
2. Writing the Code
Now that you're set up, open up the LocalScript
. The first thing you want to do is use WaitForChild()
to ensure the script will not crash if the brick has not loaded yet:
local brick=game.ReplicatedStorage:WaitForChild("Part")
Now we have a variable named brick
. Now, we need to declare another variable with a clone of brick
:
local brick=game.ReplicatedStorage:WaitForChild("Part") local newBrick=brick:Clone()
For the final line of this script, we need to add it to the player's Camera
object:
local brick=game.ReplicatedStorage:WaitForChild("Part") local newBrick=brick:Clone() local camera=Workspace.CurrentCamera newBrick.Parent=camera
The script is finished! You can learn more about local parts here. I hope this helped!