Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage").ReplicatedStoragePackage
- local PlayersService = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local CustomEnum = require(ReplicatedStorage.Modules.CustomEnum)
- local fightRemote = ReplicatedStorage.Remotes.FightRemote
- local guiUpdater = ReplicatedStorage.Remotes.AttackGuiUpdater
- local abilityFetcher = ReplicatedStorage.Remotes.AbilityFetcher
- local attackGui = script.Parent
- local attackButton = attackGui.Attack
- local abilityButton = attackGui.Ability
- local defendButton = attackGui.Defend
- local skipButton = attackGui.Skip
- local damageLabel = attackGui.DamageLabel
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- guiUpdater.OnClientEvent:Connect(function(playerTurns, playedTurns, turns, damage)
- if damage then
- damageLabel.Visible = true
- damageLabel.Text = tostring(damage) .. ' DMG'
- task.delay(1, function()
- damageLabel.Visible = false
- end)
- if not playerTurns then
- return
- end
- end
- attackGui.TurnLabel.Text = "Turn: " .. turns
- if playerTurns[playedTurns] == player.UserId then
- attackGui.YourTurnLabel.Text = "Your Turn!"
- else
- if playerTurns[playedTurns] == 0 then
- attackGui.YourTurnLabel.Text = "Enemy AI Turn"
- else
- if RunService:IsStudio() then
- attackGui.YourTurnLabel.Text = "PLACEHOLDER" .. "'s Turn"
- else
- attackGui.YourTurnLabel.Text = PlayersService:GetNameFromUserIdAsync(playerTurns[playedTurns]) .. "'s Turn"
- end
- end
- end
- end)
- skipButton.MouseButton1Click:Connect(function()
- fightRemote:FireServer(CustomEnum.AttackType.Skip)
- end)
- attackButton.MouseButton1Click:Connect(function()
- fightRemote:FireServer(CustomEnum.AttackType.Attack)
- end)
- abilityButton.MouseButton1Click:Connect(function()
- for i = 1, 3 do
- attackGui["Ability" .. i].Visible = not attackGui["Ability" .. i].Visible
- end
- local result: {string} = abilityFetcher:InvokeServer()
- for i = 1, 3 do
- attackGui["Ability" .. i].TextLabel.Text = result[i]
- end
- end)
- defendButton.MouseButton1Click:Connect(function()
- fightRemote:FireServer(CustomEnum.AttackType.Defend)
- end)
- for i = 1, 3 do
- attackGui["Ability" .. i].MouseButton1Click:Connect(function()
- fightRemote:FireServer(CustomEnum.AttackType.Ability, i)
- for i = 1, 3 do
- attackGui["Ability" .. i].Visible = not attackGui["Ability" .. i].Visible
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement