Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local player = Players.LocalPlayer
- local prisonIntro =
- workspace:WaitForChild("PrisonIntro")
- local guard =
- prisonIntro:WaitForChild("Guard")
- local dialog =
- guard:WaitForChild("Head")
- :WaitForChild("Dialog")
- local guardChoice =
- dialog:WaitForChild("GuardChoice")
- local startGuardDeparture =
- ReplicatedStorage:WaitForChild(
- "StartGuardDeparture"
- )
- --------------------------------------------------
- -- Состояние
- --------------------------------------------------
- local choiceAlreadySelected = false
- --------------------------------------------------
- -- Начальное состояние
- --------------------------------------------------
- if dialog:GetAttribute("Ready") ~= true then
- print(
- "[GUARD DIALOG] Guard ещё не готов"
- )
- end
- --------------------------------------------------
- -- Следим за Ready
- --------------------------------------------------
- dialog:GetAttributeChangedSignal(
- "Ready"
- ):Connect(function()
- local ready =
- dialog:GetAttribute("Ready")
- if ready then
- print(
- "[GUARD DIALOG] Guard готов к диалогу"
- )
- choiceAlreadySelected = false
- else
- print(
- "[GUARD DIALOG] Диалог Guard закрыт"
- )
- end
- end)
- --------------------------------------------------
- -- DialogChoiceSelected
- --------------------------------------------------
- dialog.DialogChoiceSelected:Connect(
- function(selectedPlayer, selectedChoice)
- --------------------------------------------------
- -- Только текущий игрок
- --------------------------------------------------
- if selectedPlayer ~= player then
- return
- end
- --------------------------------------------------
- -- Только наш GuardChoice
- --------------------------------------------------
- if selectedChoice ~= guardChoice then
- return
- end
- --------------------------------------------------
- -- Guard должен быть готов
- --------------------------------------------------
- if dialog:GetAttribute("Ready")
- ~= true then
- print(
- "[GUARD DIALOG] Guard ещё не готов"
- )
- return
- end
- --------------------------------------------------
- -- Не отправляем выбор дважды
- --------------------------------------------------
- if choiceAlreadySelected then
- return
- end
- choiceAlreadySelected = true
- print(
- "[GUARD DIALOG] GuardChoice выбран"
- )
- --------------------------------------------------
- -- Отправляем серверу
- --------------------------------------------------
- startGuardDeparture:FireServer()
- end
- )
Advertisement
Add Comment
Please, Sign In to add comment