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

How do I make someones face texture remove from pessing a GUI?

Asked by 4 years ago

I made a script that removes a player's face when pressing a GUI. The problem is that the face only removes a player's face on their own screen. Example: Player A presses "remove face" and the face is only shown as blank on their screen, everyone else in the game will still see Player A as having a face on their own screens.

Script:

function onClicked(hit)

game.Workspace.LocalPlayer.Character.Head.face.Texture = ""

end

script.Parent.MouseButton1Click:connect(onClicked)

0
The script is correct, but the reason it only shows up on their screen is because you made it a localscript, try making it a normal script. AronIZCool 11 — 4y

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

Introduction & Understanding


The reasoning behind this issue is mainly due to FilteringEnabled. Before continuing, please learn more about this by watching this quick video covering a bit of FE, and some reading. It’s mandatory you gather a collective knowledge on this as it is an imposed requirement as of ROBLOX’s Experimental Mode update of early September 2017. It’s also quite interesting and can increase performance between both the Client and the Server.


FilteringEnabled prevents automatic communication of LocalScripts to ServerScripts, primarily to reduce the probability of exploitation. Though because of this, these Scripts have been ultimately divided into their proper relationships.

LocalScripts - Client, ServerScripts - Server

Meaning that any work related or directed towards these categories can only be achievable accordingly. Though loopholes can achieve some amount of work in its opposite.

Why is this an issue? The Server is responsible for replicating all actions from the Client to all other affiliated Clients. If this action is severed—which is our situation—all changes made on one end will not be properly replicated to everyone else’s

FilteringEnabled doesn’t fully cut off communication though, it only prevents automatic communication. You can learn how to gain manual connection between these Scripts with RemoteEvents


Going About Fixing Your Issue

To fix your problem, add a RemoteEvent in ReplicatedStorage and create a ServerScript within ServerScriptService. Then write the following:

--// ServerScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

function ChangeCharacterAppearance(Player)
    if not (Player) then return end
    local Character = Player.Character
    if (Character) then
        local Face = Character:FindFirstChild("Head").Face
        if (Face) then
            Face.Texture = ""
        end 
    end
end

RemoteEvent.OnServerEvent:Connect(ChangeCharacterAppearance)

--// LocalScript

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")

local Button = script.Parent

Button.MouseButton1Click:Connect(function()
    RemoteEvent:FireServer()
end)

Lowercase Connect Was Deprecated

• Though this still works, it's preferred that all developers become accustomed to the renewed functions. Please use :Connect().


References & Read-ups

Eperimental Mode | Lay-over video | Stackoverflow post | Remote Events |


Hope this helps! Or brings you into the world of FE, if so don’t forget to accept and upvote! Questions, like me to further interpret? Comment!

Ad

Answer this question