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
01local plr = game.Players.LocalPlayer.Character
02local VS = script.Parent.VisorSelect
03 
04function onClick(mouse)
05    if not plr:findFirstChild("Helm") then return end
06    if not plr.Helm:findFirstChild("Visor") then return end
07    if VS.Value == true then
08        VS.Value = false
09        plr.Helm.Visor.Transparency = .8
10        plr.Head.Transparency = 0
11        script.Parent.Visor.Text = "Visor [OFF]"
12    else
13        VS.Value = true
14        plr.Helm.Visor.Transparency = 0
15        plr.Head.Transparency = 1
16        script.Parent.Visor.Text = "Visor [ON]"
17    end
18end
19 
20script.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:

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

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

01-- Server script
02game.ReplicatedStorage.yourRemoteEventName.OnServerEvent:Connect(function(player, VS)
03    local gui = VS.Parent  
04 
05    if VS.Value == true then
06        VS.Value = false
07            plr.Helm.Visor.Transparency = .8
08            plr.Head.Transparency = 0
09            gui.Visor.Text = "Visor [OFF]"
10    else
11        VS.Value = true
12        plr.Helm.Visor.Transparency = 0
13        plr.Head.Transparency = 1
14        gui.Visor.Text = "Visor [ON]"
15    end
16end)

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