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

How to make a model that only 1 player can see?

Asked by 7 years ago
Edited 7 years ago

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)

2 answers

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

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!

0
Thank you it worked! robloxy0123 30 — 7y
0
But i have a question now my other scripts don't work how can i fix this? robloxy0123 30 — 7y
0
FE is known to break scripts itsJooJoo 195 — 7y
0
FE changes how script work. It does not break them. You have to learn how to fix these things. User#11440 120 — 7y
View all comments (2 more)
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 marcoantoniosantos3 200 — 7y
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. M39a9am3R 3210 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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/!

Answer this question