Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make it so only 1 person can see an object?

I'm pretty confused on this topic. I've looked around and found some things but nothing really explaining how to do it. I know that I have to set the parent of the part into the player's camera for only them to see it, but I'm not quite sure how to do this.

Sorry I've already deleted the script that I had so far that didn't work, but basically once the player joins, there is a model containing everything that I want in the player's camera. The model is cloned from somewhere and inserted into the camera making it so only the player can see the object.

What I'm trying to do is have a NPC run after you, but I don't want it running after other people. I want it so each person gets there own NPC that runs after only them. Also sorry for making this long thanks for reading though.

Any answers would be appreciated as I've been stuck on this for the past few days.

One of the forums I found concerning this topic

v v v

https://forum.roblox.com/Forum/ShowPost.aspx?PostID=50360102

1 comment

0

Did you not follow the steps of what you should do before you post a question?

2 answers

✓ Accepted answer

With FilteringEnabled toggled on, (property of workspace), simply create a part via a Local Script, somewhere local scripts run in, like ReplicatedFirst.

Any changes made via a LocalScript with FilteringEnabled toggled on will remain local, and not replicate to the server. (except in some special cases)

-- local script in ReplicatedFirst with FilteringEnabled toggled on

local p = Instance.new("Part")
p.Parent = workspace
p.Position = Vector3.new(0,0,0)

EDIT:

Here's an example for your case:

-- local script in ReplicatedFirst with FilteringEnabled toggled on
local npc = game.ReplicatedStorage:WaitForChild("NPC") -- make sure you put NPC in repStorage
local partToTouch = workspace:WaitForChild("Part")

local plr = game.Players.LocalPlayer

partToTouch.Touched:Connect(function(hit)
	if(game.Players:GetPlayerFromCharacter(hit.Parent)==plr)then
		npc:Clone().Parent = workspace
	end
end)

2 comments

0

Ah, you beat me to it! Anyways, a more sensible place for your LocalScripts would be StarterPlayerScripts in this case.

1

No.

The best solution would be to turn on FilteringEnabled and then create those objects on the clients. That way the server will block replication regarding those objects, but they will function just fine for their respective players.

This discussion is preserved as it was. New answers, comments, and votes are closed.