LocalPart Improvement

Hello Fellow Developers,

I’m trying to create a LocalPart script. There are plenty of tutorial on the internet about this matter, but most of them seem to use finicky strategies such as placing scripts in StarterGUI that exploit the system more than untilising it.

So, I’m mainly trying to see if there is a better method or strategy to resolve this.


1 Like

FilteringEnabled already does all of this job for you. Any parts created or destroyed on the client will only show up on that client, and won’t replicate to the server. When a server does any change to a part, it will replicate to ALL clients.

So if you just want to create a part that only a specific player sees, just create it on their client, inside a LocalScript.

1 Like

Where would I store this part? The tutorials I’ve seen simply use StarterGUI.

ReplicatedStorage is a good place to originally hold the part(s).
It needs to be accessible to the client.

If you mean where it has to go, you can just set the parent to the workspace.

1 Like

StarterGui will work for what you are trying to achieve, but I would avoid it. The reason why many tutorials use it is because they were made before StarterPlayer service was added. Placing local stuff in Lighting was also a thing back then.

StarterPlayer contains StarterCharacterScripts which will run its contents every time the character is spawned and StarterPlayerScripts which will run when the player is loaded. StarterPlayerScripts should be generally used for LocalScripts that only need to be run once.

ModuleScripts can be also stored in ReplicatedStorage or ReplicatedFirst if you want them to be accessible from LocalScripts, though they can be placed into pretty much anything else. ReplicatedFirst acts just like ReplicatedStorage, but its contents are loaded before scripts get executed so it’s good for loading your game.

1 Like

Don’t fully understand what you’re trying to do but :
all should be in a local script, separately for what you’re trying to achieve, and the part itself should be in replicated storage there is no need to load it before anything else in replicated first unless you’re trying to do something with datastores/

       --this one is for creating a part just shown to one client/player upon clicking a gui object
local player = game:GetService("Players").LocalPlayer
	local part = Instance.new("Part")
	    part.Parent = workspace
	part.Position = Vector3.new(1068, 113, -501)--at this position
	part.Name = "My part"
	part.BrickColor=BrickColor.new("Bright blue")

--or  a script for getting a part from replicated storage and showing it to a certain player

script.Parent.MouseButton1Click:Connect(function()--when the button is clicked , then..
	local playes_to_rep_to= {
		"My player name";
	if table.find(playes_to_rep_to,plr.Name)
	then local cp = game.ReplicatedStorage.Part:Clone()
		cp.Parent = workspace
	--or for simply replicating a part to players of a team on joining
	if player.Team.Name == "ThisTeamGetsToSeeThisPart.."
	then local plrt = player
	game.ReplicatedStorage.Part:Clone().Parent = plrt

–edit, took me a minute it shouldnt be that complicated, unless i dont understand your issue that is

1 Like