Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Character Customization script only shows changes for the player?

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.

4 comments

0

localscripts dont affect the server, they only change stuff on your screen. use a remote event connected to a server script

0
0

Bryce, but how? I'm just a beginner.

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.

1 answer

✓ Accepted answer

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

4 comments

0

RemoteEvent's are better stored in ReplicatedStorage, as it is a shared space between the Client & Server.

0

Sure! Thats something i forgot to mention.

0

What am i supposed to do, and which script do i use?

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 :/

This discussion is preserved as it was. New answers, comments, and votes are closed.