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

Character Customization script only shows changes for the player?

Asked by 3 years ago
Edited 3 years ago

So i made this MouseButton1Click (GUI) script.

local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    local model = game.Workspace[Player.Name]

    local children = model:GetDescendants()
    for i , v in pairs(children) do 
        if v:IsA("BasePart") then 
            v.Color = Color3.new(0.235294, 0.898039, 1)
            game.Workspace[Player.name].Chest1.Eye.Color = Color3.new(0, 0, 0)
            game.Workspace[Player.name].Chest1.FaceMask1.Color = Color3.new(1, 1, 1)
            game.Workspace[Player.name].Chest1.FaceMask2.Color = Color3.new(1, 1, 1)
        end
    end
end)

And it would change the character's color, but it would show up THE CHANGES for the player that clicked the button.

0
localscripts dont affect the server, they only change stuff on your screen. use a remote event connected to a server script Brycefitz2008 2 — 3y
0
^ this and also id recommend checking out https://developer.roblox.com/en-us/articles/Roblox-Client-Server-Model Benbebop 1049 — 3y
0
Bryce, but how? I'm just a beginner. OreyTheOre 52 — 3y
0
Think of the meaning of "local". A LocalScript runs in a domestic environment; the program is executed on your device through the ROBLOX Player Application, rather than on a Server. Ziffixture 6913 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Since roblox added FE, local scripts doesn't affect the server. What you need to do is create a remote event (You can place it inside the script) and then fire it on the MouseButtonClick1 function.

--LOCAL SCRIPT

local Player = game.Players.LocalPlayer
local RemoteEvent = script.RemoteEvent -- Assuming you placed it inside the script

script.Parent.MouseButton1Click:Connect(function()
    RemoteEvent:FireServer()
end)

Okay, now you have triggered the Remote Event and you want the character changes to happen on the server, to do that you need to run the code in a script. You can put it wherever you want, but to keep things organized I would put it in the same Parent or inside the local script

--SCRIPT

local RemoteEvent = script.Parent.RemoteEvent -- Assuming you placed the script inside the local script

RemoteEvent.OnServerEvent:Connect(function(player)
    local model = player.Character

    for i, v in pairs(model:GetChildren()) do
        if v:IsA("BasePart") then
            v.Color = Color3.new(0.235294, 0.898039, 1)
            model.Chest1.Eye.Color = Color3.new(0, 0, 0)
            model.Chest1.FaceMask1.Color = Color3.new(1, 1, 1)
            model.Chest1.FaceMask2.Color = Color3.new(1, 1, 1)
        end
    end
end)

If I have a typo I’m sorry, but that should give you an idea of how to use Remote Events

0
RemoteEvent's are better stored in ReplicatedStorage, as it is a shared space between the Client & Server. Ziffixture 6913 — 3y
0
Sure! Thats something i forgot to mention. thaylerfg 30 — 3y
0
What am i supposed to do, and which script do i use? OreyTheOre 52 — 3y
0
Well, I believe I explained the steps on my answer... You need one local script, normal script and a remote event and just follow what i said :/ thaylerfg 30 — 3y
Ad

Answer this question