#Click System
1 messages · Page 1 of 1 (latest)
** You are now Level 2! **
whats the problem?
Yo chatgpt is off the bean 😭
this cannot be from chatgpt this is too horrible 😭
wym
this he means
When you run out of the free 4o model it writes code like this lol
Did you use chatgpt
i got chatgpt plus 
Me too
peak

My friend @small owl
Are you just trying to make a little delay before you click?
If so “wait()” is much better than an entire function called debouncr
YES YES YES
thats what im trying
Send the script here pls I’ll fix
local clickButton = script.Parent
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvents = replicatedStorage:WaitForChild("remoteEvents")
local clickEvent = remoteEvents:WaitForChild("click")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
function debounce(func)
local isRunning = false
return function ()
if not isRunning then
isRunning = true
wait (0.05)
func()
isRunning = false
end
end
end
clickButton.MouseButton1Up:Connect(debounce(function()
clickEvent:FireServer(player)
end)
What are you talking about
where did you even get this from? chatgpt wont write code like this
It’s to add a delay to a button click????
No if he just want his game to feel unresponsive then just wait before firing the event
either way here's a guide on how debounce works https://create.roblox.com/docs/scripting/debounce
If you were smart you’d realize it doesn’t need to be a denounce
he wants that the players can only click it like 1 time every 0.1 secs
He still needs to learn tho
Ah
I’m here to help not teach
Maybe a bit of both
also looks like you're just missing a closing ) at the end
@small owl what’s the script for
what does it need to be then..?
uhhh insert that one quote about that one firsherman
Ok what’s the click for
Do you want to disable the button for 0.05 seconds
Or you just want a delay
like
So they cannot spam it
why
So they can’t spam it?
ye
local clickButton = script.Parent
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvents = replicatedStorage:WaitForChild("remoteEvents")
local clickEvent = remoteEvents:WaitForChild("click")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
function debounce(func)
local isRunning = false
return function()
if not isRunning then
isRunning = true
wait(0.05)
func()
isRunning = false
end
end
end
clickButton.MouseButton1Up:Connect(debounce(function()
clickEvent:FireServer(player)
end)) -- ← this closing parenthesis was missing
Yep
U should put the air on the other side of the func() and use task.wait
or its not even counting
local clickButton = script.Parent
local clickEvent = remoteEvents:WaitForChild("click")
local player = game.Players.LocalPlayer
local cooldown = false
clickButton.MouseButton1Up:Connect(function()
if cooldown then return end
cooldown = true
clickEvent:FireServer(player)
task.delay(0.1, function()
cooldown = false
end)
end)
try this
that would depend on the receiving end of clickEvent.OnServerEvent
And this isn’t gonna work since ur defining a new variable each time meaning it just sets to false
mb dont try that
holy fuck
local clickButton = script.Parent
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvents = replicatedStorage:WaitForChild("remoteEvents")
local clickEvent = remoteEvents:WaitForChild("click")
local player = game.Players.LocalPlayer
local cooldown = false
clickButton.MouseButton1Up:Connect(function()
if cooldown then return end
cooldown = true
clickEvent:FireServer(player)
task.delay(0.1, function()
cooldown = false
end)
end)
it should be a image button right?
their code does not define a new variable each time
like I put an image button
is actually kinda clever way to wrap a function in a debounce
Ty
Sorry for earlier pyro I was wrong
In denounce()
It makes a new a variable, called isRunning and that just set to false
@small owl we cannot make your game man
But we might be talking bout different scripts I think
debounce() returns a function which is what is being connected to
it is not connecting to debounce
that's why kinda clever way of doing it ;p
Are you paying them?
that
that whenb I click the button it doesnt count the click
to the leaderboard
That depends entirely on the script for your leaderboard
We don’t know the variables and such
also side note the wait() should be after the func() call, not before 
local dataStoreService = game:GetService("DataStoreService")
local clickDataStore = dataStoreService:GetDataStore("Clicks")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local clicks = Instance.new("IntValue", leaderstats)
clicks.Name = "Clicks"
clicks.Value = 0
local playerUserId = "player_"..player.UserId
--Loading Data--
local clicksData
local success, errormessage = pcall(function()
clicksData = clickDataStore:GetAsync(playerUserId)
end)
if success then
clicks.Value = clicksData
end
end)
--Saving Data
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = "player_"..player.UserId
local clicksValue = player.leaderstats.Clicks.Value
local success, errornessage = pcall(function()
clickDataStore:SetAsync(playerUserId, clicksValue)
end)
end)
game:BindToClose(function(player)
local playerUserId = "player_"..player.UserId
local clicksValue = player.leaderstats.Clicks.Value
local success, errornessage = pcall(function()
clickDataStore:SetAsync(playerUserId, clicksValue)
end)
end)
dont judge the script
Good catch lol
im doing my best
where is clickEvent.OnServerEvent?
@fleet sedge would this work tho?
yeah, but i dont think you need the task.delay, you can just task.wait
its not
lol
well that's probably why its not doing anything, if you haven't connected the server-side of clickEvent:FireServer(player), which side note you also don't need to include player in that since it is sent automatically with remote events
this looks fine for what it is, i mean it's clearly someone's first datastore code but i mean on the surface it looks like it'll work fine. just don't make the newbie mistake of changing the leaderstats on the client 
i think I made
where should I put that
wherever you want
ima start crying 😭
if you want to try your hand at making the server side of the fireserver, here's a guide on how remote events work https://create.roblox.com/docs/scripting/events/remote
maybe I should not touch script again