Help with local scripts and the server

Hello. Sorry for all the forum posts lol.
In my game, the player can choose to change their colour.
However, this is done by a local script in a GUI button.

Once the player changes their colour, only they can see it. I understand that I could use a remote event, but I have no idea how I would go about actually using it so that the whole server can see the player’s new colour.

Here is the local script:
image

thanks!

2 Likes

You are doing it on the client you need to do it on the server try using a remote event then put this script in serverscriptStorage:

local remote = ----your remote 

 remote.OnServerEvent:connect(function(plr)
      plr.Character.Torso.Color = Color3.fromRGB(252, 61, 78)
  end)

Then in your local script add this line

   local remote = ---again your remote

    
 script.Parent.MouseButton1Click:Connect(function()
        remote:FireServer()
   end)
2 Likes

Yeah hes on the client!
!!!

1 Like

OnServerEvent can only be used on the server
on the local script

I did mention

OnserverEvent can only be used in Script it won’t work on local script

Oh ok I didn’t read well
Thx for telling me :slight_smile:

1 Like

I checked again on the script Onserverevent is on the serverscriptservice and it is script
image

Its coming from the client and the local

Send me your script and send me which one is local and which one is not like show me the workspace because I suppose you wrote onserver event on the client because it says Client-LocalScript

alright
image

Ok so firstly in the remote variable you didn’t specify the remote event it should be local remote = game.ReplicatedStorage.RemoteEvent

And for the local script first you didn’t specify the remote second mouse button 1 click is for gui button plus you wrote an onServerEvent in the local script

Ohhhh.
Ok I was that dumb
ty for telling me then!

1 Like

hi!
I did this, and no errors occurred, however, it is still not showing for other players.

It should,

SERVER SCRIPT

local Remote = game.ReplicatedStorage.REMOTES.ChangeColor --edit this to where yours is stored

Remote.OnServerEvent:Connect(function(Player)
	Player.Character.Torso.Color = Color3.fromRGB(252, 61, 78)
	print("color changed")
end)

CLIENT

local Remote = game.ReplicatedStorage.REMOTES.ChangeColor --edit this to where yours is stored
local Player = game.Players.LocalPlayer
local Character = Player.Character

script.Parent.MouseButton1Click:Connect(function()
	Remote:FireServer(Player)
	print("fired")
end)

Make sure you put the “Script” in ServerScriptService then put the localscript in the GUI that gets clicked if that’s how you have it set up.

Boys, we finally found the britisher

1 Like