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

FilteringEnabled & Local Parts?

Asked by
Uroxus 350 Moderation Voter
7 years ago

Basically my game has FilteringEnabled on (have not used this before) and I need to show a model only to the player when they join...

I've come up with this in a local script, inside *StarterPlayerScripts * under StarterPack. It works in normal studio test mode yet when I start a Test Server only the player's name is printed and nothing gets moved....

local player = game.Players.LocalPlayer

if player.Name == "Player1" or player.Name == "Player" then
    print(player.Name)
    local clone = game.ServerStorage.ShipModel:Clone()
    clone.Parent = game.Workspace
    print("Cloned and moved")
end

Any help is appreciated, thanks :)

2 answers

Log in to vote
2
Answered by
StoIid 364 Moderation Voter
7 years ago
Edited 7 years ago

This is because local scripts cannot access game.ServerStorage

For more information on LocalScripts please visit this link.

0
Forgot he's putting it in workspace? ._. Abstract_Life 65 — 7y
0
Doesn't matter, ServerStorage is practically invisible to the LocalScript so it can't "find" the Model in the first place. StoIid 364 — 7y
Ad
Log in to vote
1
Answered by 7 years ago

So if you want the model to only be viewed by the player them selves. im sure you can do that with FE, but your better off putting it in the players camera by doing the following:

local player = game.Players.LocalPlayer
if player.Name == "Player1" or player.Name == "Player" then
    print(player.Name)
    game.ReplicatedStorage.ShipModel:Clone().Parent = game.Workspace.CurrentCamera
    print("Cloned and moved")
end

You should have used Replicated storage, you used server storage

local clone = game.ServerStorage.ShipModel:Clone()

And camera is a good way to keep things local.

Answer this question