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 a model that only 1 player can see?

Hello i want to make a model when you click on a button 1 player can see what happend (the one who clicked the button) and the other players can't see it because they have to click on the button.

Can someone help me with this?

function onClicked()
if script.Parent.Value.Value == true then
script.Parent.Value.Value = false
script.Parent.BrickColor = BrickColor.new("Bright red")
script.Parent.Parent.Parent.lightning.ParticleEmitter.Enabled = false
script.Parent.Parent.Parent.lightning2.ParticleEmitter.Enabled =  false
script.Parent.Parent.Union.ParticleEmitter.Enabled = true
script.Parent.Parent.Parent.smoke.Sound2.Looped = true
script.Parent.Parent.Parent.smoke.Sound2:Play()
wait(2)
script.Parent.Value.Value = true
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 comment

2 answers

✓ Accepted answer

Use a Local Script.

To do this method, you're going to need Filtering Enabled on. FE is a property of workspace.

Simply copy and paste your code into a local script, and move that script to StarterPack.

Now you're going to have to re-define the Click Detector, but this isn't hard.

-- Local Script in StarterPack
function onClicked()
	if script.Parent.Value.Value == true then
		script.Parent.Value.Value = false
		script.Parent.BrickColor = BrickColor.new("Bright red")
		script.Parent.Parent.Parent.lightning.ParticleEmitter.Enabled = false
		script.Parent.Parent.Parent.lightning2.ParticleEmitter.Enabled =  false
		script.Parent.Parent.Union.ParticleEmitter.Enabled = true
		script.Parent.Parent.Parent.smoke.Sound2.Looped = true
		script.Parent.Parent.Parent.smoke.Sound2:Play()
		wait(2)
		script.Parent.Value.Value = true
	end
end
workspace.Part.ClickDetector.MouseClick:connect(onClicked)-- Get Click Detector

This is just one of the ways you can make Local Parts. It's best to always use Filtering Enabled, but it can me hard to learn at first.

Good Luck!

6 comments

0

Thank you it worked!

0

But i have a question now my other scripts don't work how can i fix this?

0

FE is known to break scripts

0

FE changes how script work. It does not break them. You have to learn how to fix these things.

0

FE isn't needed, as it also makes local scripts' do nothing on server, this is, to other players. I recommend you to turn off FE, and do part.Parent = workspace.CurrentCamera. Robloxy, if it breaks your other scripts downvote this answer and unaccept it

0

There is no need to downvote each other. My opinion, if you're not advanced or you're too far along in the development process of your game use CurrentCamera. If you know how to, use FilteringEnabled. However I encourage both of you to provide such option. You two do not need to downvote each other.

There are two ways to do this, I will be using the one that does not require FilteringEnabled (FE.) Mainly because it doesn't require you to change all of your other scripts to work with it.

Useful Resources:

http://wiki.roblox.com/index.php?title=API:Class/Workspace/CurrentCamera http://wiki.roblox.com/index.php?title=API:Class/LocalScript

Alright, what you'd need to do is have a LocalScript somewhere within the player or character (this includes PlayerGui/StarterGui, Backpack, Humanoid, etc.)

In that LocalScript, you will be inserting a part into the local player's CurrentCamera, like so:

Local Part Insertion LocalScript in StarterGui

local localCamera = game.Workspace.CurrentCamera
Insert.new("Part", localCamera)

Anything in the local player's CurrentCamera can only be seen by that player.

The downside with using this technique, though, is that scripts cannot run inside CurrentCamera, so I do not suggest using this technique if you have scripts in those parts or anything like that. A solution to this is to have the scripts outside of CurrentCamera, yet the parts inside, and edit that parts that way.

I also suggest that you learn to use FilteringEnabled: http://wiki.roblox.com/index.php?title=Client-Server_Model_and_FilteringEnabled

If you found my solution helpful, consider leaving an upvote and accepting my answer. Also, check out my website: http://robloxguides.com/!

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