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)
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
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)