Decal/Face Changer works but not on other players screens

I’m trying to make my GUI Work properly.

So i made a face changing GUI And it opens and closes and the face changes but i have one small problem. The face doesn’t show that it is changed for other players. What am i doing wrong in my script?

It works in game not just studio, and the face changer works for other players but it wont show the changed face for other players screens but the player who changes their own face can see the changed face. I’m very confused lol, Theres no errors in output either.

image

local Player = game.Players.LocalPlayer

local UI = Player.PlayerGui.ScreenGui.ImageButton.Makeupgooi.Makeup4

UI.MouseButton1Click:connect (function()

Player.Character.Head.face.Texture = UI.Image

end)

Anyone know what to do?

1 Like

I’m pretty sure this is because you’re doing it on the Client, not the server. If you fire an event and do it through a server script then it should work I think.

You need to use Remote objects to pull this off as you can’t change a Player’s character from a LocalScript and have it replicate to the server. You would need to do something like:

-- SERVER
ChangeFace.OnServerEvent:Connect(function(player, newFace)
    -- change player face here
end)

You should consider doing a for-loop here to map a MouseButton1Down event for all your images so you don’t have to copy and paste the same block of code over and over again.

-- CLIENT
ChangeFace:FireServer(UI.Image)
2 Likes

3 things.
1: You should be using RemoteEvents for this. The RemoteEvent will then tell the server what it wants. You’ll need to add some protection to the event to prevent exploiters from doing unwanted functions. If the client can see the change but nobody else can, it’s most likely an issue with the Client-Server Boundary. RemoteEvents and RemoteFunctions are the only ways around the boundary.
2: connect is depricated. You shoud be using Connect instead.
3: You shouldn’t use a Server Script inside of a PlayerGui. Instead use a LocalScript with RemoteEvents and RemoteFunctions as stated in #1.

You’ll also want to read up on loops as @Qxest recommended.

for i,v in pairs(Location_Of_Buttons:GetChildren()) do
    v.MouseButton1Click:Connect(function()
        -- The code to run
    end
end)

See https://developer.roblox.com/articles/Remote-Functions-and-Events

1 Like