#Click System

1 messages · Page 1 of 1 (latest)

small owl
#

Idk how to fix this

neon oreBOT
#

studio** You are now Level 2! **studio

scarlet otter
#

whats the problem?

chrome jasper
#

Yo chatgpt is off the bean 😭

scarlet otter
#

this cannot be from chatgpt this is too horrible 😭

tidal night
scarlet otter
small owl
#

idk how to script

#

only build and model

chrome jasper
chrome jasper
small owl
#

nonono

#

i tried chatgpt to correct

tidal night
#

After closer inspection

#

What the fucl

scarlet otter
#

peak

small owl
#

like

#

it should

#

add clicks

#

to the leaderboard

#

when I click the button

#

right?

tidal night
chrome jasper
#

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

small owl
#

thats what im trying

chrome jasper
scarlet otter
#

wait() wont work

#

you need the debounce

small owl
#

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)

chrome jasper
fleet sedge
chrome jasper
#

It’s to add a delay to a button click????

tidal night
#

No if he just want his game to feel unresponsive then just wait before firing the event

fleet sedge
chrome jasper
scarlet otter
tidal night
chrome jasper
#

Maybe a bit of both

fleet sedge
chrome jasper
#

@small owl what’s the script for

fleet sedge
tidal night
small owl
#

the click

chrome jasper
#

Do you want to disable the button for 0.05 seconds

#

Or you just want a delay

small owl
#

like

chrome jasper
#

So they cannot spam it

small owl
#

it should be a "click simulator"

#

i want a little delay

tidal night
chrome jasper
#

So they can’t spam it?

small owl
#

ye

chrome jasper
#

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

small owl
#

it was the

#

parenthesis

chrome jasper
#

Yep

small owl
#

but still

#

when I click

#

it doesnt go up to the leaderboard

tidal night
small owl
#

or its not even counting

scarlet otter
#
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

fleet sedge
tidal night
#

And this isn’t gonna work since ur defining a new variable each time meaning it just sets to false

scarlet otter
#

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)
small owl
fleet sedge
small owl
#

like I put an image button

fleet sedge
#

is actually kinda clever way to wrap a function in a debounce

chrome jasper
#

Sorry for earlier pyro I was wrong

tidal night
chrome jasper
#

@small owl we cannot make your game man

tidal night
#

But we might be talking bout different scripts I think

fleet sedge
#

it is not connecting to debounce

fleet sedge
#

that's why kinda clever way of doing it ;p

small owl
#

but the stupid scripter is sleeping

#

what could be the error

chrome jasper
small owl
#

that

small owl
#

its a friend

small owl
#

to the leaderboard

chrome jasper
#

That depends entirely on the script for your leaderboard

#

We don’t know the variables and such

fleet sedge
#

also side note the wait() should be after the func() call, not before hehe

small owl
#

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

small owl
#

im doing my best

fleet sedge
scarlet otter
tidal night
fleet sedge
small owl
chrome jasper
fleet sedge
# small owl its not

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

fleet sedge
small owl
#

i think I made

fleet sedge
small owl
#

here?

#

but still doesnt work

fleet sedge
# small owl

lol server:fireserver hehe maybe you should just wait for your friend

scarlet otter
#

ima start crying 😭

fleet sedge
small owl