I'm doing a mini-game where players can equip skins. In the lobby I wanted to set up statues that show each player their own skin I tried this:
local player = game.Players.LocalPlayer wait (0.1) while true do wait (1) if game.Players.LocalPlayer.Backpack.Skins.Weapons.AK12.Value == 1 then script.Parent.Parent.Parent.BrickColor = BrickColor.new("Bright blue") script.Parent.Parent.Parent.Material = ('SmoothPlastic') end end
but obviously it does not work because a script has no local player
Client-Server Replication
With FilteringEnabled, LocalScript
s have great importance. A LocalScript
cannot access top-level services such as ServerScriptService
, HttpService
, etc. Aswell as changes made to the client are NOT replicated to the server. This will allow us to make weapon
See this setup. Assume I have a LocalScript
in StarterPlayerScripts
to change a brick's color, I want Player1
to have a green brick, and Player2
to have a blue brick. I can do the following code:
local plr = game.Players.LocalPlayer if plr.Name == "Player1" then game.Workspace.Brick.BrickColor = BrickColor.new("green") end if plr.Name == "Player2" then game.Workspace.BrickColor = BrickColor.new("blue") end
Player1 would see Brick
as green, and Player2
as blue. You can use this same setup for skins, changing it's physical properties aswell as it's size, rotation, etc.
Note that It has to be in a LocalScript!!. If it's in a ServerScript then it'll be replicated to EVERY player.