I did have help on this before but never understood how to actually disconnect the function while still being able to use it - my fix was to use a debounce but i want to actually use :Once but also be able to use it again? if that makes sense?
Server Script - click button to play claw machine
--Variables here
local Price = 10
ClickDetector.MouseClick:Connect(function(player)
if inUse.Value then
player.PlayerGui.ClawMachine.ClawInUse.Visible = true
task.wait(5)
player.PlayerGui.ClawMachine.ClawInUse.Visible = false
else
firepurchasegui:FireClient(player)
end
end)
Server fires client (firepurchasegui:FireClient(player))
Local Script - Receives FireClient - Stays running continously
firepurchasegui.OnClientEvent:Connect(function(player) --Connect function
purchase.Visible = true
--Another connect function causing double firing and keeping the function active
play.MouseButton1Click:Connect(function()
firepurchasegui:FireServer()
purchase.Visible = false
end)
quit.MouseButton1Click:Connect(function()
purchase.Visible = false
end)
end)
Client fires server (firepurchisegui:FireServer())
Server Script - Receives FireServer - Double fires
firepurchasegui.OnServerEvent:Connect(function(player)
if player.leaderstats.Coins.Value < Price then
player.PlayerGui.ClawMachine.PurchaseFail.Visible = true
task.wait(2)
player.PlayerGui.ClawMachine.PurchaseFail.Visible = false
else
Datamanager.remCoins(player, Price)
print(Price)
player.PlayerGui.ClawMachine.PurchaseSuccess.Visible = true
task.wait(2)
player.PlayerGui.ClawMachine.PurchaseSuccess.Visible = false
fireclientgui:FireClient(player)
inUse.Value = true
end
end)
** You are now Level 7! **