I'm trying to make it so that when you click a button, the union (food)'s transparency goes 0. Right clicking changes it back to 1. Here is my script if needed.
local Food = game.Workspace.Food
function leftClick() Food.Transparency = 0 end
function rightClick() Food.Transparency = 1 end
script.Parent.MouseButton1Click:Connect(leftClick) script.Parent.MouseButton2Click:Connect(rightClick)
EDIT: I forgot to mention, I want to make it so that it pops up in everyones screen. Right now, it's in a local script and putting it on a regular script wont work. It works fine, but it only pops up in my screen.
To make this, you will need to know how to use: RemoteEvent
In a LocalScript
, we will connect to two events of TextButton
local Event = game.ReplicatedStorage.RemoteEvent -- Change RemoteEvent to the name of the RemoteEvent script.Parent.MouseButton1Click:Connect(function() Event:FireServer(1) end) script.Parent.MouseButton2Click:Connect(function() Event:FireServer(0) end)
This will fire the event with one of the arguments: 1, 2.
Now in a script that's in ServerScriptService, add:
local Event = game.ReplicatedStorage.RemoteEvent -- Change RemoteEvent to the name of the RemoteEvent Event.OnServerEvent:Connect(function(Player, Transparency) game.Workspace.Food.Transparency = Transparency end)
I hope it helped!