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

How do I make my Surface GUIs FilteringEnabled compatible?

Asked by 6 years ago

I have a soda machine that only works when FilteringEnabled is disabled. It uses a Surface GUI to select the flavor you want and a part that you touch your cup to in order to fill the cup. Here is one of the flavor selection scripts:

local CurrentFlavor = script.Parent.Parent.Parent.Parent.CurrentFlavor
local Pour = script.Parent.Parent.Parent.Parent.Pour
local light = script.Parent.Parent.Parent.Parent.Parent.Parent.Light

function fill()
    light.BrickColor = BrickColor.new("Lime green")
    CurrentFlavor.Value = "Coke"
    Pour.TextBox.Text = " Ready To Pour "..CurrentFlavor.Value.."..."
    Pour.Visible = true
    wait(5)
    light.BrickColor = BrickColor.new("Institutional white")
    Pour.Visible = false
    CurrentFlavor.Value = "Nothing"
end

script.Parent.MouseButton1Click:Connect(fill)

CurrentFlavor: The String Value that tells a touched event what drink to pour.

Pour: The frame that appears when you have selected a flavor.

Light: The light that turns green when you have selected a flavor.

Here is part of the touched part script:

local CupName = "Empty Glass"

local CurrentFlavor = script.Parent.Parent.Screen.SurfaceGui.CurrentFlavor
local spill = script.Parent.Spill

function hit(hit)
    if CurrentFlavor.Value == "Coke" and hit.Parent.Name == CupName then
        spill.BrickColor = BrickColor.new("Cocoa")
        spill.Transparency = 0
        wait(1)
        hit.Parent.Drink.BrickColor = BrickColor.new("Cocoa")
        hit.Parent.Drink.Transparency = 0
        hit.Parent.Name = "Coke"
        spill.Transparency = 1

end

    end

    script.Parent.Touched:Connect(hit)

There are a bunch of elseifs for the other drink flavors.

Thanks!

2 answers

Log in to vote
0
Answered by 6 years ago

I am not really good with FilteringEnabled, as I have made a question about it a few minutes ago, but I knew some main points.

METHOD 1: RemoteMadness

You can't change objects from the client. What you have created was a LocalScript. The LocalScript works on the player's computer, rather than the server. Because FilteringEnabled prevents exploiters from changing values or objects from the client, it also can't let a legitimate person too. In order to filter out the exploiters, you need to use some things called RemoteEvents and Functions. There is a Roblox wiki on this, you can see it here:

https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

Anyways, you have to call an event from the client to the server (like transmitting a signal from your computer to scriptinghelpers.org). A script can check if this event is called, and make the light turn green, once a flavor has been selected. So, only Scripts have access to objects, and not LocalScripts.

METHOD 2: The old fashioned way

The second method is to use buttons, rather than the madness above. Sure, it looks really ugly, but it will save you a lot of time, and it is still FilteringEnabled-friendly. You can make a part, then put a ClickDetector on, then you can use the onMouseClick function. This is an empty button:

local part = Instance.new("Part")
local clickDetector = Instance.new("ClickDetector")

local function onMouseClick(player)

end


clickDetector.MouseClick:connect(onMouseClick)

0
Thanks! I know a bit about remote events, yet the scripts that I tried only work for Screen GUIs and not Surface GUIs :/ Lama_llama 8 — 6y
0
So, you want a soda machine as a 2d GUI? sahadeed 87 — 6y
0
The screen is basically like a touch screen. Lama_llama 8 — 6y
0
Just because the second method works fine with FE set on in the properties window doesn't mean your game is secure. Turning on the option FE doesn't give you any security benefits. T0XN 276 — 6y
View all comments (2 more)
0
That is why you must use RE and RF. T0XN 276 — 6y
0
I got it working. I inserted a Click Detector to bring up a Screen Gui, then used a Remote Event to select the flavor. Lama_llama 8 — 6y
Ad
Log in to vote
-1
Answered by 6 years ago

If the SurfaceGui is placed in the Workspace, put it in StarterGui, then set its "Adornee" to the part you want it to be adorned (place in front of) to. Since after all, it IS a ****GUI****

Answer this question