Hi im currently trying to make a script where the player can use a cash register but if they try to claim/use multiple it will FireServer on the one they was using. I have tried re writing the code that stops them from clicking the same register twice but instead it does nothing.
local CashierScreen = script.Parent
local Events = game.Workspace.Tech2.Events
local Events1 = game.Workspace.Tech.Events
local ordering = false
local groupId = 3433019
local function onClaim(Player)
if Player == game.Players.LocalPlayer then
CashierScreen.Claim.Visible = false
CashierScreen.Main.Visible = true
CashierScreen.Main.Cashier.Text = "Current Cashier: "..Player.Name.." ("..Player:GetRoleInGroup(groupId)..")"
elseif Player then
CashierScreen.Claim.Visible = false
CashierScreen.Used.Visible = true
CashierScreen.Used.Welcome.Text = "This lane is in use by "..Player.Name..". Please use another one."
else
CashierScreen.Claim.Visible = true
CashierScreen.Used.Visible = false
CashierScreen.Main.Visible = false
end
end
Events.Claim.OnClientEvent:Connect(onClaim)
CashierScreen.Claim.Claim.MouseButton1Click:Connect(function()
if script.Using.Value.Value then
game.StarterGui:SetCore("SendNotification", {
Title = "Error!",
Text = "You can only use one cash register at a time!",
})
else
Events.Claim:FireServer()
script.Using.Value.Value = true
end
end)
CashierScreen.Main.Close.MouseButton1Click:Connect(function()
Events.Claim:FireServer()
script.Using.Value.Value = false
end)
CashierScreen.Main.Clear.MouseButton1Click:Connect(function()
ordering = false
Events.Order:FireServer()
CashierScreen.Main.New.Visible = true
CashierScreen.Main.Checkout.Visible = false
CashierScreen.Main.Close.Size = UDim2.new(1, 0, 0, 100)
CashierScreen.Main.Clear.Visible = false
CashierScreen.Main.Buttons.Visible = false
CashierScreen.Main.Receipt.Visible = false
end)
I added the first registers events ( the script is to allow the player to use the second register) but i dont know the code which would prevent the player from claiming the first register whilst in use of the second one or if they do they would switch which from the one they are using. Does anyone know how to help?