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

How would I make something visible to the client but not to the server?

Asked by 7 years ago

I know the easiest way to make something visible only to one person is to parent a Model to the CurrentCamera using a localscript (keep in mind I am referencing a group of Parts, here, not a GUI item). The last time I did something like this, however, the model started having rendering problems and would glitch out when unanchored -- both problems are unrelated, it would seem. So how would I get, for example, a Character Creator model of the character being created to be seen in a menu screen only by the player, and not by others, if I can avoid having to use the CurrentCamera?

1 answer

Log in to vote
1
Answered by 7 years ago

You can use Filtering Enabled. Filtering Enabled keeps your game secure by not allowing the client to replicate to the server. In other words, the client can't change the server in any way.

'How can we get around this?' you may be asking. Remote Events and Remote Functions are the way to go.

This allows the client to communicate to the server to change things in the server.

Now back to your question. How can we make something visible to the client but not the server? Well Remote Events and Remote Functions allow us to change things in the client. You can read more about them with the links I have attatched. Here's an example of a script that creates a part only visible to the client when they join the game:

Script

--This is a script as a child of ServerScriptService
--Make sure there is a remote event in replicated storage

game.Players.PlayerAdded:connect(function(player)
    local event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
    event:FireClient(player)
end)

LocalScript

--This localscript is a child of StarterPlayerScripts

local event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")

event.OnClientEvent:connect(function()
    Instance.new("Part", workspace)
end)
0
I hope this sums it up. Please tell me if I made an error with my code. UltimateRaheem 75 — 7y
Ad

Answer this question