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