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

Is it possible to make a part in the workspace look different for each player?

Asked by 5 years ago
Edited 5 years ago

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

0
Describe your problem a little more. What does the script more, and add more detail to what you want to achieve User#19524 175 — 5y

1 answer

Log in to vote
1
Answered by
green271 635 Moderation Voter
5 years ago

Client-Server Replication

With FilteringEnabled, LocalScripts 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.

Ad

Answer this question