# Как сделать простой симулятор клика в Roblox Studio

В этой статье рассмотрим как можно сделать простой симулятор клика в Roblox Studio. Из функционала в нем будет одна кнопка которую игроки должны будут нажимать и счетчик который будет выводить на экран количество нажатий по кнопке, а так же небольшая таблица лидеров.

1. В первую очередь **создаем ScreenGui внутри StarterGui.**

> Для того что бы создать ScreenGui внутри StarterGui необходимо навести на StarterGui, нажать на появившуюся кнопку [![Кнопки в Roblox Studio](https://game-roblox.ru/wp-content/uploads/2022/05/3.png)](https://game-roblox.ru/wp-content/uploads/2022/05/3.png) и найти в выпавшем списке ScreenGui. Найти его достаточно просто, для этого начните вводить в поиске ScreenGui.

<figure><img src="https://game-roblox.ru/wp-content/uploads/2022/05/Screenshot_1-2.jpg" alt=""><figcaption></figcaption></figure>

Переименовываем **ScreenGui** в **Menu** для удобства

<figure><img src="https://game-roblox.ru/wp-content/uploads/2022/05/Screenshot_2.jpg" alt=""><figcaption></figcaption></figure>

Теперь нужно создать кнопку которую будет нажимать игрок. Для этого внутри **Menu** создаем **TextButton** и размещаем ее в нужной части экрана

<figure><img src="https://game-roblox.ru/wp-content/uploads/2022/05/Screenshot_3.jpg" alt=""><figcaption></figcaption></figure>

Настраиваем его цвет, размер текста и переименовываем по желанию

<figure><img src="https://game-roblox.ru/wp-content/uploads/2022/05/Screenshot_4-1.jpg" alt=""><figcaption></figcaption></figure>

Этот скрипт выведет таблицу лидеров. Внутри **ServerScriptService** создайте **Script** и пропишите в нем этот код :

```lua
game.Players.PlayerAdded:Connect(function(plr)
local ls = Instance.new("Folder",plr)
ls.Name = "leaderstats"
local clicks = Instance.new("IntValue",ls)
clicks.Name = "Taps"
clicks.Value = 0
end)
```

<figure><img src="https://game-roblox.ru/wp-content/uploads/2022/05/Screenshot_5-1.jpg" alt=""><figcaption></figcaption></figure>

Этот скрипт отвечает за работу кнопки. Внутри кнопки **«Клик»** создайте **LocalScript** и пропишите в нем этот код:

```lua
local clicks = game.Players.LocalPlayer.leaderstats.Taps
local de = false
local T = 0.1
script.Parent.MouseButton1Click:Connect(function()
if de then
return
end
de = true
clicks.Value += 1
wait(T)
de = false
end)
```

<figure><img src="https://game-roblox.ru/wp-content/uploads/2022/05/Screenshot_6-1.jpg" alt=""><figcaption></figcaption></figure>

Внутри **Menu** создайте **TextLabel**, разместите его в нужной части экрана и настройте внешний вид (так же как с кнопкой).

<figure><img src="https://game-roblox.ru/wp-content/uploads/2022/05/Screenshot_8.jpg" alt=""><figcaption></figcaption></figure>

Этот скрипт отвечает за работу вашего личного счетчика кликов. Внутри **TextLabel** создайте **LocalScript** и пропишите в нем следующий код :

```lua
local clicks = game.Players.LocalPlayer.leaderstats.Taps
while wait() do
script.Parent.Text = "Taps: " .. clicks.Value
end
```

<figure><img src="https://game-roblox.ru/wp-content/uploads/2022/05/Screenshot_7-1.jpg" alt=""><figcaption></figcaption></figure>

Готово, можно запускать симуляцию и тестировать.

<figure><img src="https://game-roblox.ru/wp-content/uploads/2022/05/Screenshot_9.jpg" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lahmeneffa.gitbook.io/roblox/uroki-roblox-studio/kak-sdelat-prostoi-simulyator-klika-v-roblox-studio.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
