Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I got an error on my clicker game, what i have to do?

Error : Mouse1Click is not a valid member of ServerScriptService

local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:FindFirstChild("ButtonClick")
 
local button = script.Parent
 
local debounce = false
 
button.Mouse1Click:Connect(function()
    if not debounce then
        debounce = true
        local playerPoint = game.Players.LocalPlayer.leaderstats.Points
        remote:FireServer(playerPoint)
        wait(0.01)
        debounce = false
    end
end)

https://imgur.com/a/uEVsPaA

2 comments

0

What do you do with the 'playerPoint' you send to the server? You should only tell the server that they clicked. Not send a current value of something to be added. You risk the client exploiting the amount here.

0

Also 'Mouse1Click' isn't an event for any object in Roblox. I'm assuming you mean 'MouseButton1Click' for a GuiButton: https://developer.roblox.com/api-reference/event/GuiButton/MouseButton1Click

2 answers

✓ Accepted answer

Your script is fine (i rearranged some things so its a bit more organized)

local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:FindFirstChild("ButtonClick")
local player = game.Players.LocalPlayer

local button = script.Parent

local debounce = false

button.Activated:Connect(function()
	if debounce == true then return end
	debounce = true
		local playerPoint = player.leaderstats.Points
		remote:FireServer(playerPoint)
		wait(0.01)
	debounce = false
end)

When you write

local button = script.Parent

make sure this refers to a TextButton or Image Button in a GUI under StarterGui

It seems as if you have used, "Mouse1Click" which isn't a valid property of the mouse.

local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:FindFirstChild("ButtonClick")

local button = script.Parent

local debounce = false

button.MouseButton1Down:Connect(function()
    if not debounce then
        debounce = true
        local playerPoint = game.Players.LocalPlayer.leaderstats.Points
        remote:FireServer(playerPoint)
        wait(0.01)
        debounce = false
    end
end)

5 comments

0

This should work, and if it does please accept my answer!

0

Didn't even notice that, nice work!

0

Doesn't work...

0

what's the error, and use prints

0

Yeah, what are the errors?

This discussion is preserved as it was. New answers, comments, and votes are closed.