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

Hey, would anyone be able to help me fix this script to filtering enabled?

Asked by 5 years ago
local plr = game.Players.LocalPlayer.Character
local VS = script.Parent.VisorSelect

function onClick(mouse)
    if not plr:findFirstChild("Helm") then return end
    if not plr.Helm:findFirstChild("Visor") then return end
    if VS.Value == true then
        VS.Value = false
        plr.Helm.Visor.Transparency = .8
        plr.Head.Transparency = 0
        script.Parent.Visor.Text = "Visor [OFF]"
    else
        VS.Value = true
        plr.Helm.Visor.Transparency = 0
        plr.Head.Transparency = 1
        script.Parent.Visor.Text = "Visor [ON]"
    end
end

script.Parent.Visor.MouseButton1Click:connect(onClick)

So, what this is meant to do is that the player puts on a morph and the helmet has a little clickable gui on the top left that's called "Visor" and when the user clicks it the visor goes transparent but I'm having trouble on working how to make it work with filtering enabled since only the client can see the transparency change to the visor.

https://gyazo.com/aa496f5e65a46bc40bb0606b8c7f6f9d ~ What it looks like in the workspace

I sort of know you need to do a RemoteEvent but not really sure how I would do it.

1 answer

Log in to vote
0
Answered by
bluzorro 417 Moderation Voter
5 years ago

The RemoteEvent has to be after the 2 lines of code which are:

if not plr:findFirstChild("Helm") then return end if not plr:findFirstChild("Visor") then return end

Create a RemoteEvent in ReplicatedStorage and name it whatever you want, then after the 2 statements, write this:

-- Local script
game.ReplicatedStorage.yourRemoteEventName:FireServer(VS) -- cut the code past the 2 "return end" statements.

After that, create a script, preferably in serverscriptservice, and write this:

-- Server script
game.ReplicatedStorage.yourRemoteEventName.OnServerEvent:Connect(function(player, VS)
    local gui = VS.Parent   

    if VS.Value == true then
        VS.Value = false
            plr.Helm.Visor.Transparency = .8
            plr.Head.Transparency = 0
            gui.Visor.Text = "Visor [OFF]"
    else
        VS.Value = true
        plr.Helm.Visor.Transparency = 0
        plr.Head.Transparency = 1
        gui.Visor.Text = "Visor [ON]"
    end
end)

Also, you should make a variable inside the serverscript for the gui. Accept this answer if it worked, and ask me if something went wrong.

Ad

Answer this question