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

Making it so all players can see changes to a player's character(FE)?

Asked by 7 years ago

I recently made my game FilteringEnabled. I have a character creation GUI in the beginning of the game when a player joins and it changes the characters face, shirt, pants, etc. Before Filtering, all players could see the changes done (shirts changing, pants changing, etc). But after Filtering, only the localplayer sees the items being changed on his/her character.

local player = game.Players.LocalPlayer
local Character = player.Character
if not Character or not Character.Parent then
    Character = player.CharacterAdded:wait()
end


script.Parent.MouseButton1Down:connect(function()
    local Head = Character.Head
    local BodyColors = Character:FindFirstChild("Body Colors")
    local Shirt = Character:FindFirstChild("Shirt")
    local Pants = Character:FindFirstChild("Pants")
    if Shirt then
        Shirt.ShirtTemplate = "rbxassetid://629730174"
    else
        local Shirt = Instance.new("Shirt", Character)
        Shirt.ShirtTemplate = "rbxassetid://629730174"
    end
    if Pants then
        Pants.PantsTemplate = "rbxassetid://629736312"
    else
        local Pants = Instance.new("Pants", Character)
        Pants.PantsTemplate = "rbxassetid://629736312"
    end
    for i,v in pairs(Character:GetChildren()) do
        if v.ClassName == "Accessory" then
            v:Destroy()
        end
    end
    for i,v in pairs(Character:GetChildren()) do
        if v.ClassName == "Hat" then
            v:Destroy()
        end
    end
    --local hat = game.ReplicatedStorage.NerdHair:Clone()
    --hat.Parent = Character
    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local WallyHat = ReplicatedStorage.Remote.WallyHat
    WallyHat:FireServer()
    Head.face.Texture = "rbxassetid://144763383"
    BodyColors.RightArmColor = BrickColor.new("Reddish brown")
    BodyColors.LeftArmColor = BrickColor.new("Reddish brown")
    BodyColors.LeftLegColor = BrickColor.new("Reddish brown")
    BodyColors.RightLegColor = BrickColor.new("Reddish brown")
    BodyColors.TorsoColor = BrickColor.new("Reddish brown")
    BodyColors.HeadColor = BrickColor.new("Reddish brown")
    local c = Character:FindFirstChild("TheFlash")
    if c then
        c:Destroy()
    end
    Character.Zoom:Destroy()
    Character.ReverseFlash:Destroy()
    Character.BlackFlash:Destroy()
    local t = game:GetService('UserInputService').TouchEnabled
    if t == true then
    player.PlayerGui.Teleport.Minus.Visible = true
    player.PlayerGui.Teleport.Plus.Visible = true
    player.PlayerGui.Teleport.Walkspeed.Visible = true
else
    player.PlayerGui.ControlHUD.Frame.Visible = true
    script.Parent.Parent.Parent.Parent:Destroy()
end
end)

I'm not sure but I think I would need to use a RemoteEvent and use FireAllClients(). Can someone point me in the right direction?

1 answer

Log in to vote
1
Answered by
TrippyV 314 Donator Moderation Voter
7 years ago

FilteringEnabled can be tricky, but you can't change anything in a LocalScript without it being local. You need to use a server script, RemoteEvents, and FireServer.

Put this in a server script in ServerScriptService:

local Event = Instance.new("RemoteEvent")
Event.Name = "ChangeShirt"
Event.Parent = game.ReplicatedStorage

local Event2 = Instance.new("RemoteEvent")
Event2.Name = "ChangePants"
Event2.Parent = game.ReplicatedStorage

local Event3 = Instance.new("RemoteEvent")
Event3.Name = "ChangeBodyColors"
Event3.Parent = game.ReplicatedStorage

Event.OnServerEvent:connect(function(plr, id, shirt)
    if shirt ~= nil then
        shirt.ShirtTemplate = id
    else
        shirt = Instance.new("Shirt", plr.Character)
        shirt.ShirtTemplate = id
    end

    for i,v in pairs(plr.Character:GetChildren()) do
        if v.ClassName == "Accessory" then
            v:Destroy()
        end
    end

    for i,v in pairs(plr.Character:GetChildren()) do
            if v.ClassName == "Hat" then
                    v:Destroy()
            end
    end
end)

Event2.OnServerEvent:connect(function(plr, id, pants)
    if pants ~= nil then
        pants.PantsTemplate = id
    else
        pants = Instance.new("Pants", plr.Character)
        pants.PantsTemplate = id
    end
end)

Event3.OnServerEvent:connect(function(plr)
    plr.Character.Head.face.Texture = "rbxassetid://144763383"
    if plr.Character:FindFirstChild("Body Colors") ~= nil then
        local BodyColors = plr.Character:FindFirstChild("Body Colors")
            BodyColors.RightArmColor = BrickColor.new("Reddish brown")
            BodyColors.LeftArmColor = BrickColor.new("Reddish brown")
            BodyColors.LeftLegColor = BrickColor.new("Reddish brown")
            BodyColors.RightLegColor = BrickColor.new("Reddish brown")
            BodyColors.TorsoColor = BrickColor.new("Reddish brown")
            BodyColors.HeadColor = BrickColor.new("Reddish brown")
    end
        local c = plr.Character:FindFirstChild("TheFlash")
        if c then
            c:Destroy()
        end
    plr.Character.Zoom:Destroy()
    plr.Character.ReverseFlash:Destroy()
        plr.Character.BlackFlash:Destroy()
end)

Now this should be your LocalScript:

local player = game.Players.LocalPlayer
local Character = player.Character
if not Character or not Character.Parent then
    Character = player.CharacterAdded:wait()
end

local ChangeShirt = game.ReplicatedStorage:WaitForChild("ChangeShirt")
local ChangePants = game.ReplicatedStorage:WaitForChild("ChangePants")
local ChangeColors = game.ReplicatedStorage:WaitForChild("ChangeBodyColors")

script.Parent.MouseButton1Down:connect(function()
    local Head = Character.Head
    local BodyColors = Character:FindFirstChild("Body Colors")
    local Shirt = Character:FindFirstChild("Shirt")
    local Pants = Character:FindFirstChild("Pants")
    if Shirt then
        ChangeShirt:FireServer("rbxassetid://629730174",Shirt)
    else
        ChangeShirt:FireServer("rbxassetid://629730174")
    end
    if Pants then
        ChangePants:FireServer("rbxassetid://629736312",Pants)
    else
        ChangePants:FireServer("rbxassetid://629736312")
    end
    --local hat = game.ReplicatedStorage.NerdHair:Clone()
    --hat.Parent = Character
    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local WallyHat = ReplicatedStorage.Remote.WallyHat
    WallyHat:FireServer()
    ChangeColors:FireServer()
    local t = game:GetService('UserInputService').TouchEnabled
    if t == true then
    player.PlayerGui.Teleport.Minus.Visible = true
    player.PlayerGui.Teleport.Plus.Visible = true
    player.PlayerGui.Teleport.Walkspeed.Visible = true
else
    player.PlayerGui.ControlHUD.Frame.Visible = true
    script.Parent.Parent.Parent.Parent:Destroy()
end
end)

This should all (in theory) work as you want, if anything goes wrong feel free to comment and I'll try to respond as quick as possible.

Ad

Answer this question