Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by 7 years ago
Edited 6 years ago

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

0
Did you not follow the steps of what you should do before you post a question? hiimgoodpack 2009 — 7y

Locked by Goulstem

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
3
Answered by
CootKitty 311 Moderation Voter
7 years ago
Edited 7 years ago

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)
0
Ah, you beat me to it! Anyways, a more sensible place for your LocalScripts would be StarterPlayerScripts in this case. gskw 1046 — 7y
1
No. CootKitty 311 — 7y
Ad
Log in to vote
1
Answered by
gskw 1046 Moderation Voter
7 years ago

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.