Help with remote event script

i put in starterplayer
but now where do i put the debounce

Look here:


local BloxyColaButton = game.Workspace.CashRegister1.BloxyColaButton
local BurgerButton = game.Workspace.CashRegister1.BurgerButton
local FriesButton = game.Workspace.CashRegister1.FriesButton
local PizzaButton = game.Workspace.CashRegister1.PizzaButton
local TacoButton = game.Workspace.CashRegister1.TacoButton
local ordering = false – debounce variable

game.ReplicatedStorage.CustomerOrder1.OnClientEvent:Connect(function()

	if ordering then return end 

local Buttons = math.random(1,5)
print(Buttons)

if Buttons == 1 then
	BloxyColaButton.Material = Enum.Material.Neon
end

if Buttons == 2 then
	BurgerButton.Material = Enum.Material.Neon
end

if Buttons == 3 then
	FriesButton.Material = Enum.Material.Neon
end

if Buttons == 4 then
	PizzaButton.Material = Enum.Material.Neon
end

if Buttons == 5 then
	TacoButton.Material = Enum.Material.Neon
end

end)

Like this?

almost. You’re missing ordering=true

i need to add that when i finish my script, right?

and also in the random math script, when a button is randomly chosen, i want to add that the player needs to click it to get a money reward. If was to add that, how would i write it?

My thought process when you ask this is as follows:
In what way can I detect a click on a part?
To answer this, there are 2 main ways:

  1. Use a ClickDetector
  2. Use Mouse.Target

Then I thought: well if you use ClickDetector you would have to connect a function to every single click detector and then probably use a bindable event to know when a single click is done to a part. This wouldn’t be a bad option.

However if you use Mouse.Target, you simply wait for the user to click and then see what is inside of Mouse.Target. If it is the part that was highlighted, then you unhighlight the option and set ordering to false.

I have to go for now.
Sorry. -------

ok ill try my best, but if i need u ill try sending u a message

You’re using a remote event for server-to-server interactions, use a bindable.

whats a bindable event? and where do i use it?

Tutorial on how: