Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

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. xPolarium 1388 — 5y
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 xPolarium 1388 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

Ad
Log in to vote
1
Answered by 5 years ago

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)

0
This should work, and if it does please accept my answer! MustangHeart 67 — 5y
0
Didn't even notice that, nice work! DesiredRep 75 — 5y
0
Doesn't work... rosebeach -3 — 5y
0
what's the error, and use prints DesiredRep 75 — 5y
0
Yeah, what are the errors? MustangHeart 67 — 5y

Answer this question