remove the while true do. Just have everything inside it be there on it’s own.
------------------------------------------------------------------------- Game Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local Teams = game:GetService("Teams")
------------------------------------------------------------------------- Remote Functions
local OrderBloxyColaEvent = ReplicatedStorage:WaitForChild("OrderBloxyCola")
local OrderPizzaEvent = ReplicatedStorage:WaitForChild("OrderPizza")
local OrderBurgerEvent = ReplicatedStorage:WaitForChild("OrderBurger")
local OrderFriesEvent = ReplicatedStorage:WaitForChild("OrderFries")
local OrderTacoEvent= ReplicatedStorage:WaitForChild("OrderTaco")
------------------------------------------------------------------------- Cash Register Buttons
local BloxyColaButton = Workspace.CashRegister1.BloxyColaButton
local BurgerButton = Workspace.CashRegister1.BurgerButton
local FriesButton = Workspace.CashRegister1.FriesButton
local PizzaButton = Workspace.CashRegister1.PizzaButton
local TacoButton = Workspace.CashRegister1.TacoButton
local ProximityPrompt = workspace.Customer1.Torso.ProximityPrompt
------------------------------------------------------------------------- Player and leaderstats
local Player = game.Players.LocalPlayer
------------------------------------------------------------------------- Button can give money
local BloxyColaMoney = false
local TacoMoney = false
local FriesMoney = false
local BurgerMoney = false
local PizzaMoney = false
local PlayerWhoClickedIsCashier = false
-------------------------------------------------------------------------
function OnClicked1(Player)
if BloxyColaMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
BloxyColaButton.Material = Enum.Material.Plastic
BloxyColaMoney = false
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
function OnClicked2(Player)
if TacoMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
TacoButton.Material = Enum.Material.Plastic
TacoMoney = false
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
function OnClicked3(Player)
if FriesMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
FriesButton.Material = Enum.Material.Plastic
FriesMoney = false
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
function OnClicked4(Player)
if BurgerMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
BurgerButton.Material = Enum.Material.Plastic
BurgerMoney = false
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
function OnClicked5(Player)
if PizzaMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
PizzaButton.Material = Enum.Material.Plastic
PizzaMoney = false
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
BloxyColaButton.ClickDetector.MouseClick:Connect(OnClicked1)
TacoButton.ClickDetector.MouseClick:Connect(OnClicked2)
FriesButton.ClickDetector.MouseClick:Connect(OnClicked3)
BurgerButton.ClickDetector.MouseClick:Connect(OnClicked4)
PizzaButton.ClickDetector.MouseClick:Connect(OnClicked5)
OrderBloxyColaEvent.OnServerEvent:Connect(function()
BloxyColaMoney = true
end)
OrderTacoEvent.OnServerEvent:Connect(function()
TacoMoney = true
end)
OrderFriesEvent.OnServerEvent:Connect(function()
FriesMoney = true
end)
OrderBurgerEvent.OnServerEvent:Connect(function()
BurgerMoney = true
end)
OrderPizzaEvent.OnServerEvent:Connect(function()
PizzaMoney = true
end)
yes it is working, the print works, the enable proximity prompt works, the BurgerMoney = false works, but the only thing not working is the change material.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local OrderBloxyColaEvent = ReplicatedStorage:WaitForChild("OrderBloxyCola")
local OrderPizzaEvent = ReplicatedStorage:WaitForChild("OrderPizza")
local OrderBurgerEvent = ReplicatedStorage:WaitForChild("OrderBurger")
local OrderFriesEvent = ReplicatedStorage:WaitForChild("OrderFries")
local OrderTacoEvent= ReplicatedStorage:WaitForChild("OrderTaco")
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)
if Buttons == 1 then
BloxyColaButton.Material = Enum.Material.Neon
OrderBloxyColaEvent:FireServer(BloxyColaButton)
print("BloxyCola")
end
if Buttons == 2 then
BurgerButton.Material = Enum.Material.Neon
OrderBurgerEvent:FireServer(BurgerButton)
print("Burger")
end
if Buttons == 3 then
FriesButton.Material = Enum.Material.Neon
OrderFriesEvent:FireServer(FriesButton)
print("Fries")
end
if Buttons == 4 then
PizzaButton.Material = Enum.Material.Neon
OrderPizzaEvent:FireServer(PizzaButton)
print("Pizza")
end
if Buttons == 5 then
TacoButton.Material = Enum.Material.Neon
OrderTacoEvent:FireServer(TacoButton)
print("Taco")
end
end)
Okay, I see the problem you are changing the Part to Neon on the Client Side, you are trying to change it to Plastic on the Server Side which still thinks the part is plastic, to fix this you have to use a remote event to change the material on the client side.
So you want to make one remote event (call it like ChangeMaterial) in ReplicatedStorage, then in a local script (in either StarterPlayerScripts or StarterGui place this code:
local RS = game:GetService("ReplicatedStorage")
local ChangeMaterialEvent = RS.ChangeMaterial
ChangeMaterialEvent.OnClientEvent(function(Part, Material)
Part.Material = Material
end)
Next back into your script
Add this variable at the top: local ChangeMaterial = game.ReplicatedStorage.ChangeMaterial
And everywhere you change the material to plastic replace it for ChangeMaterial:FireClient(Player, Part, Enum.Material.Plastic)
So for example,
Would become: ChangeMaterial:FireClient(Player, BloxyColaButton, Enum.Material.Plastic)
------------------------------------------------------------------------- Game Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local Teams = game:GetService("Teams")
------------------------------------------------------------------------- Remote Functions
local OrderBloxyColaEvent = ReplicatedStorage:WaitForChild("OrderBloxyCola")
local OrderPizzaEvent = ReplicatedStorage:WaitForChild("OrderPizza")
local OrderBurgerEvent = ReplicatedStorage:WaitForChild("OrderBurger")
local OrderFriesEvent = ReplicatedStorage:WaitForChild("OrderFries")
local OrderTacoEvent= ReplicatedStorage:WaitForChild("OrderTaco")
local ChangeMaterial = game.ReplicatedStorage.ChangeMaterial
------------------------------------------------------------------------- Cash Register Buttons
local BloxyColaButton = Workspace.CashRegister1.BloxyColaButton
local BurgerButton = Workspace.CashRegister1.BurgerButton
local FriesButton = Workspace.CashRegister1.FriesButton
local PizzaButton = Workspace.CashRegister1.PizzaButton
local TacoButton = Workspace.CashRegister1.TacoButton
local ProximityPrompt = workspace.Customer1.Torso.ProximityPrompt
------------------------------------------------------------------------- Player and leaderstats
local Player = game.Players.LocalPlayer
------------------------------------------------------------------------- Button can give money
local BloxyColaMoney = false
local TacoMoney = false
local FriesMoney = false
local BurgerMoney = false
local PizzaMoney = false
local PlayerWhoClickedIsCashier = false
-------------------------------------------------------------------------
function OnClicked1(Player)
if BloxyColaMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
ChangeMaterial:FireClient(Player, BloxyColaButton, Enum.Material.Plastic)
BloxyColaMoney = false
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
function OnClicked2(Player)
if TacoMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
ChangeMaterial:FireClient(Player, TacoButton, Enum.Material.Plastic)
TacoMoney = false
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
function OnClicked3(Player)
if FriesMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
ChangeMaterial:FireClient(Player, FriesButton, Enum.Material.Plastic)
FriesMoney = false
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
function OnClicked4(Player)
if BurgerMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
ChangeMaterial:FireClient(Player, BurgerButton, Enum.Material.Plastic)
BurgerMoney = false
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
function OnClicked5(Player)
if PizzaMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
ChangeMaterial:FireClient(Player, PizzaButton, Enum.Material.Plastic)
PizzaMoney = false
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
BloxyColaButton.ClickDetector.MouseClick:Connect(OnClicked1)
TacoButton.ClickDetector.MouseClick:Connect(OnClicked2)
FriesButton.ClickDetector.MouseClick:Connect(OnClicked3)
BurgerButton.ClickDetector.MouseClick:Connect(OnClicked4)
PizzaButton.ClickDetector.MouseClick:Connect(OnClicked5)
OrderBloxyColaEvent.OnServerEvent:Connect(function()
BloxyColaMoney = true
end)
OrderTacoEvent.OnServerEvent:Connect(function()
TacoMoney = true
end)
OrderFriesEvent.OnServerEvent:Connect(function()
FriesMoney = true
end)
OrderBurgerEvent.OnServerEvent:Connect(function()
BurgerMoney = true
end)
OrderPizzaEvent.OnServerEvent:Connect(function()
PizzaMoney = true
end)
I fixed it, now one last thing my the money giver line doesnt work
--------------------------------------------------------------------- Game Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local Teams = game:GetService("Teams")
------------------------------------------------------------------------- Remote Functions
local OrderBloxyColaEvent = ReplicatedStorage:WaitForChild("OrderBloxyCola")
local OrderPizzaEvent = ReplicatedStorage:WaitForChild("OrderPizza")
local OrderBurgerEvent = ReplicatedStorage:WaitForChild("OrderBurger")
local OrderFriesEvent = ReplicatedStorage:WaitForChild("OrderFries")
local OrderTacoEvent= ReplicatedStorage:WaitForChild("OrderTaco")
------------------------------------------------------------------------- Cash Register Buttons
local BloxyColaButton = Workspace.CashRegister1.BloxyColaButton
local BurgerButton = Workspace.CashRegister1.BurgerButton
local FriesButton = Workspace.CashRegister1.FriesButton
local PizzaButton = Workspace.CashRegister1.PizzaButton
local TacoButton = Workspace.CashRegister1.TacoButton
local ProximityPrompt = workspace.Customer1.Torso.ProximityPrompt
------------------------------------------------------------------------- Player and leaderstats
local Player = game.Players.LocalPlayer
local stats = Player.leaderstats.cash
------------------------------------------------------------------------- Button can give money
local BloxyColaMoney = false
local TacoMoney = false
local FriesMoney = false
local BurgerMoney = false
local PizzaMoney = false
-------------------------------------------------------------------------
function OnClicked1(Player)
if BloxyColaMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
BloxyColaButton.Material = Enum.Material.Plastic
BloxyColaMoney = false
cash.Value = cash.Value +10000
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
end
function OnClicked2(Player)
if TacoMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
TacoButton.Material = Enum.Material.Plastic
TacoMoney = false
cash.Value = cash.Value +10000
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
end
function OnClicked3(Player)
if FriesMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
FriesButton.Material = Enum.Material.Plastic
FriesMoney = false
cash.Value = cash.Value +10000
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
end
function OnClicked4(Player)
if BurgerMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
BurgerButton.Material = Enum.Material.Plastic
BurgerMoney = false
cash.Value = cash.Value +10000
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
end
function OnClicked5(Player)
if PizzaMoney == true then
print("It Works")
ProximityPrompt.Enabled = true
PizzaButton.Material = Enum.Material.Plastic
PizzaMoney = false
cash.Value = cash.Value +10000
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
end
BloxyColaButton.ClickDetector.MouseClick:Connect(OnClicked1)
TacoButton.ClickDetector.MouseClick:Connect(OnClicked2)
FriesButton.ClickDetector.MouseClick:Connect(OnClicked3)
BurgerButton.ClickDetector.MouseClick:Connect(OnClicked4)
PizzaButton.ClickDetector.MouseClick:Connect(OnClicked5)
OrderBloxyColaEvent.OnServerEvent:Connect(function()
BloxyColaButton.Material = Enum.Material.Neon
BloxyColaMoney = true
end)
OrderTacoEvent.OnServerEvent:Connect(function()
TacoButton.Material = Enum.Material.Neon
TacoMoney = true
end)
OrderFriesEvent.OnServerEvent:Connect(function()
FriesButton.Material = Enum.Material.Neon
FriesMoney = true
end)
OrderBurgerEvent.OnServerEvent:Connect(function()
BurgerButton.Material = Enum.Material.Neon
BurgerMoney = true
end)
OrderPizzaEvent.OnServerEvent:Connect(function()
PizzaButton.Material = Enum.Material.Neon
PizzaMoney = true
end)
Once again you can’t use LocalPlayer in a regular script.
For your money adding do this in your functions;
function OnClicked1(Player)
if BloxyColaMoney == true then
local cash = Player.leaderstats.cash
print("It Works")
ProximityPrompt.Enabled = true
BloxyColaButton.Material = Enum.Material.Plastic
BloxyColaMoney = false
cash.Value = cash.Value +10000
elseif BloxyColaMoney ~= true then
print("Order not placed")
end
end
end