Advertisement
Ultimate_69

FightClient

May 21st, 2025 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage").ReplicatedStoragePackage
  2. local PlayersService = game:GetService("Players")
  3. local RunService = game:GetService("RunService")
  4.  
  5. local CustomEnum = require(ReplicatedStorage.Modules.CustomEnum)
  6.  
  7. local fightRemote = ReplicatedStorage.Remotes.FightRemote
  8. local guiUpdater = ReplicatedStorage.Remotes.AttackGuiUpdater
  9. local abilityFetcher = ReplicatedStorage.Remotes.AbilityFetcher
  10. local attackGui = script.Parent
  11.  
  12. local attackButton = attackGui.Attack
  13. local abilityButton = attackGui.Ability
  14. local defendButton = attackGui.Defend
  15. local skipButton = attackGui.Skip
  16.  
  17. local damageLabel = attackGui.DamageLabel
  18.  
  19. local player = game.Players.LocalPlayer
  20. local character = player.Character or player.CharacterAdded:Wait()
  21.  
  22. guiUpdater.OnClientEvent:Connect(function(playerTurns, playedTurns, turns, damage)
  23.     if damage then
  24.         damageLabel.Visible = true
  25.         damageLabel.Text = tostring(damage) .. ' DMG'
  26.         task.delay(1, function()
  27.             damageLabel.Visible = false
  28.         end)
  29.         if not playerTurns then
  30.             return
  31.         end
  32.     end
  33.     attackGui.TurnLabel.Text = "Turn: " .. turns
  34.     if playerTurns[playedTurns] == player.UserId then
  35.         attackGui.YourTurnLabel.Text = "Your Turn!"
  36.     else
  37.         if playerTurns[playedTurns] == 0 then
  38.             attackGui.YourTurnLabel.Text = "Enemy AI Turn"
  39.         else
  40.             if RunService:IsStudio() then
  41.                 attackGui.YourTurnLabel.Text = "PLACEHOLDER" .. "'s Turn"
  42.             else
  43.                 attackGui.YourTurnLabel.Text = PlayersService:GetNameFromUserIdAsync(playerTurns[playedTurns]) .. "'s Turn"
  44.             end
  45.         end
  46.     end
  47. end)
  48.  
  49. skipButton.MouseButton1Click:Connect(function()
  50.     fightRemote:FireServer(CustomEnum.AttackType.Skip)
  51. end)
  52.  
  53. attackButton.MouseButton1Click:Connect(function()  
  54.     fightRemote:FireServer(CustomEnum.AttackType.Attack)
  55. end)
  56.  
  57. abilityButton.MouseButton1Click:Connect(function()
  58.     for i = 1, 3 do
  59.         attackGui["Ability" .. i].Visible = not attackGui["Ability" .. i].Visible
  60.     end
  61.     local result: {string} = abilityFetcher:InvokeServer()
  62.     for i = 1, 3 do
  63.         attackGui["Ability" .. i].TextLabel.Text = result[i]
  64.     end
  65. end)
  66.  
  67. defendButton.MouseButton1Click:Connect(function()
  68.     fightRemote:FireServer(CustomEnum.AttackType.Defend)
  69. end)
  70.  
  71. for i = 1, 3 do
  72.     attackGui["Ability" .. i].MouseButton1Click:Connect(function()
  73.         fightRemote:FireServer(CustomEnum.AttackType.Ability, i)
  74.         for i = 1, 3 do
  75.             attackGui["Ability" .. i].Visible = not attackGui["Ability" .. i].Visible
  76.         end
  77.     end)
  78. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement