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

How would I go about making my GUI Filtering Enabled friendly?

Asked by
Kojouro 15
6 years ago

So, I've made a script with a GUI to where if I press a key the GUI will open and close, and I have a few other things in place. But they aren't Filtering Enabled friendly and I have no clue how to go about making them work with it.

local Prty = script.Parent.Party
local Plr = script.Parent.Player
local Sttg = script.Parent.Settings
local Bkp = script.Parent.Backpack
local Msg = script.Parent.Messages
local Map = script.Parent.Map
local Hlp = script.Parent.Help
local Tggl = true
local MenuO = script.Parent.Menu_Open
local Blr = game.Workspace.CurrentCamera.Blur

function KeyDown(OpenMenu, Toggle, Menu)
    if Toggle == Enum.UserInputState.Begin then
        if Tggl == true then
            Plr:TweenPosition(UDim2.new(0.2, 0, 0.1, 0), "Out", "Back", .75)
            Prty:TweenPosition(UDim2.new(0.2, 0, 0.2, 0), "Out", "Back", .75)
            Bkp:TweenPosition(UDim2.new(0.2, 0, 0.3, 0), "Out", "Back", .75)
            Msg:TweenPosition(UDim2.new(0.2, 0, 0.4, 0), "Out", "Back", .75)
            Map:TweenPosition(UDim2.new(0.2, 0, 0.5, 0), "Out", "Back", .75)
            Sttg:TweenPosition(UDim2.new(0.2, 0, 0.6, 0), "Out", "Back", .75)
            Hlp:TweenPosition(UDim2.new(0.2, 0, 0.7, 0), "Out", "Back", .75)
            Blr.Enabled = true
            MenuO:Play()
            Tggl = false
        else
            Prty:TweenPosition(UDim2.new(0.2, 0, -0.5, 0), "Out", "Back", .5)
            Plr:TweenPosition(UDim2.new(0.2, 0, -0.5, 0), "Out", "Back", .5)
            Sttg:TweenPosition(UDim2.new(0.2, 0, -0.5, 0), "Out", "Back", .5)
            Bkp:TweenPosition(UDim2.new(0.2, 0, -0.5, 0), "Out", "Back", .5)
            Map:TweenPosition(UDim2.new(0.2, 0, -0.5, 0), "Out", "Back", .5)
            Msg:TweenPosition(UDim2.new(0.2, 0, -0.5, 0), "Out", "Back", .5)
            Hlp:TweenPosition(UDim2.new(0.2, 0, -0.5, 0), "Out", "Back", .5)
            Blr.Enabled = false
            MenuO:Play()
            Tggl = true
        end
    end
end

game.ContextActionService:BindAction("KeyPress", KeyDown, false, Enum.KeyCode.M)
0
This is all in a LocalScript, thought I should clear that up just incase. Kojouro 15 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

What I did with my GUI is make it where when you click the button it Fires a Remote Event which will go ahead and close the GUI for the Server and Client.

These are RemoteEvents

They can be used for almost anything that is needed for the Server, they just cannot access the client.

An Example of what I did

Local Script

script.Parent.MouseButton1Click:connect(function()
    script.Parent.Exit:FireServer()
end)

Script

local GUI = script.Parent.Parent.Parent

script.Parent.Exit.OnServerEvent:Connect(function()
    GUI:Destroy()
end)

You can replace GUI with your lcoation

0
I'm really new to the whole RemoteEvents thing, and I'm still not too good at scripting normally, but if I was wanting to keep the tweening instead of destroying the GUI itself, is there a way to preserve it? Kojouro 15 — 6y
0
You don’t use remote events to hide a gui... User#19524 175 — 6y
1
There was literly no reason to downvote it not only that it wouldn't close the other GUIs not only that the code you put can be easily exploited Sergiomontani10 236 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

To close a gui, you don’t need any remote events. Only one player closes it and only their gui closes. If you made a remote event it would close all of the other guis.

But if you wanted to make a buy button, you could do this:

Server Script, handles everything:

local buyEvent = Instance.new([[RemoteEvent]], game.Workspace)
buyEvent.Name = “BuyEvent”

buyEvent.OnServerEvent:Connect(function(plr, price, tool, clone) 
    if plr.leaderstats.Money.Value >= price then
        if not tool:IsDescendantOf(plr) and not tool:IsDescendantOf(plr.Character) then
            plr.leaderstats.Money.Value = plr.leaderststs.Money.Value - price
            tool.Parent = plr.StarterGear
            clone.Parent = plr.Backpack
        end
    end
end)

LocalScript

script.Parent.MouseButton1Click:Connect(function()
    game.Workspace.RemoteEvent:FireServer(
        500,
        game:GetService([[ReplicatedStorage]])Tool:Clone(),
        game:GetService([[ReplicatedStorage]]).Tool:Clone()
)
end)

Answer this question