Here is the main-game client script:
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid") or Character:FindFirstChildOfClass("Humanoid")
local PlayerData = Player:WaitForChild("PlayerStatistics")
local PlayerStats = PlayerData:WaitForChild("Statistics")
local Camera = workspace.CurrentCamera
local CurrentArena = workspace:WaitForChild("CurrentArena")
local Folder_Assets = ReplicatedStorage:WaitForChild("Assets")
local Folder_Remotes = Folder_Assets:WaitForChild("Remotes")
local Folder_Events = Folder_Assets:WaitForChild("Events")
local Folder_Modules = Folder_Assets:WaitForChild("Modules")
local TransitionModule = require(Folder_Modules:WaitForChild("RoundTransition"))
local Folder_Models = Folder_Assets:WaitForChild("Models")
local Folder_Items = Folder_Models:WaitForChild("Items")
local Folder_Weapons = Folder_Models:WaitForChild("Weapons")
local SoundTrack = SoundService.SoundTrack
local GUI = script.Parent
local IntroFrame = GUI:WaitForChild("Intro")
local ActionFrame = GUI:WaitForChild("Actions")
--
local Dark1 = IntroFrame:WaitForChild("Darken1")
local Dark2 = IntroFrame:WaitForChild("Darken2")
local Icon = IntroFrame:WaitForChild("Icon")
local Animations = script:WaitForChild("Animations")
local ActionIdle = Humanoid:LoadAnimation(Animations:WaitForChild("ActIdle"))
local ThinkIdle = Humanoid:LoadAnimation(Animations:WaitForChild("ItemIdle"))
--
--
local TurnLabel = ActionFrame:WaitForChild("CurrentTurn")
local TurnTL = TurnLabel:WaitForChild("Team")
local ActInfo = ActionFrame:WaitForChild("Info")
local PlayerFrame = ActInfo:WaitForChild("PlayerFrame")
local EnemyFrame = ActInfo:WaitForChild("EnemyFrame")
local PlayerHP = PlayerFrame:WaitForChild("HP")
local EnemyHP = EnemyFrame:WaitForChild("HP")
local Moves = ActionFrame:WaitForChild("Moves")
local ListOfMoves = Moves:WaitForChild("List")
local TypeOfMoves = Moves:WaitForChild("Types")
local ConfirmMove = ActionFrame:WaitForChild("ConfirmMove")
local WeaponHelp = Moves:WaitForChild("WeaponInfo")
local ItemHelp = Moves:WaitForChild("ItemInfo")
local WeaponsBtn = TypeOfMoves:WaitForChild("Weapons")
local ItemsBtn = TypeOfMoves:WaitForChild("Items")
--
local FastIntroInfo = TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.InOut)
local IntroInfo = TweenInfo.new(1, Enum.EasingStyle.Back, Enum.EasingDirection.InOut)
local LongIntroInfo = TweenInfo.new(2, Enum.EasingStyle.Back, Enum.EasingDirection.InOut)
local ActionInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local HPInfo = TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)
local CurrentTurn = "Players"
local MoveChosen = false
local ChosenMusic = nil
local function DeclareTurn(Team)
if not CurrentArena:FindFirstChildOfClass("Folder") then return end
CurrentTurn = Team
TurnLabel.TypeOfAlert.Text = "NOTIFICATION"
if Team == "Players" then
TurnTL.Text = "It's your turn!"
TurnLabel.BackgroundColor3 = Color3.fromRGB(42, 152, 255)
TurnLabel.BorderColor3 = Color3.fromRGB(0, 98, 255)
elseif Team == "Enemies" then
TurnTL.Text = "It's their turn!"
TurnLabel.BackgroundColor3 = Color3.fromRGB(255, 42, 42)
TurnLabel.BorderColor3 = Color3.fromRGB(141, 0, 0)
end
task.spawn(function()
script.Notification:Play()
TweenService:Create(TurnLabel, ActionInfo, {Position = UDim2.new(0, 0,0.3, 0)}):Play()
task.wait(1.75)
TweenService:Create(TurnLabel, ActionInfo, {Position = UDim2.new(-1, 0,0.3, 0)}):Play()
end)
task.wait(1)
end
local function ClearStuff()
for _, UI in pairs(ListOfMoves:GetChildren()) do
if not UI:IsA("UIListLayout") then
UI:Destroy()
end
end
end
local function LoadStuff(Type)
local FolderOfThings = PlayerData:WaitForChild(Type)
ClearStuff()
for _, Thing in pairs(FolderOfThings:GetChildren()) do
if Type == "Items" then
for i=0, Thing.Value do
if Thing.Value <= 0 then Thing:Destroy() return end
local Template = script.ItemTemplate:Clone()
Template.Parent = ListOfMoves
Template.Item.Text = Thing.Name
local PhysicalItem = Folder_Items:WaitForChild(Thing.Name)
if PhysicalItem then
local HealthValue = PhysicalItem:WaitForChild("Heal")
local UsesValue = PhysicalItem:WaitForChild("Uses")
Template.Uses.Text = UsesValue.Value
Template.Stat.Text = HealthValue.Value
end
Template.Item.Activated:Connect(function()
if not MoveChosen then
MoveChosen = true
TweenService:Create(ConfirmMove, IntroInfo, {Position = UDim2.new(0.3, 0,0.2, 0)}):Play()
Moves.Blocker.Visible = true
TweenService:Create(Moves.Blocker, FastIntroInfo, {TextTransparency = 0.2}):Play()
task.spawn(function()
task.spawn(function()
ThinkIdle:Stop()
Humanoid.Jump = true
end)
end)
ConfirmMove.Confirm.Activated:Connect(function()
MoveChosen = true
TweenService:Create(Moves, ActionInfo, {Position = UDim2.new(-1, 0,0.6, 0)}):Play()
TweenService:Create(ConfirmMove, IntroInfo, {Position = UDim2.new(-1, 0,0.2, 0)}):Play()
Folder_Remotes.CastMove:FireServer("Item", Thing.Name)
local Arena = CurrentArena:FindFirstChildOfClass("Folder")
local ArenaCAM = Arena:WaitForChild("A_Cam")
local PlayerCAM = Arena:WaitForChild("P_Cam")
local EnemyCAM = Arena:WaitForChild("E_Cam")
task.spawn(function()
local T1 = TweenService:Create(Camera, ActionInfo, {CFrame = ArenaCAM.CFrame})
local T2 = TweenService:Create(Camera, ActionInfo, {CFrame = EnemyCAM.CFrame})
local T3 = TweenService:Create(Camera, ActionInfo, {CFrame = PlayerCAM.CFrame})
T1:Play()
T1.Completed:Wait()
T2:Play()
T2.Completed:Wait()
end)
end)
ConfirmMove.Cancel.Activated:Connect(function()
MoveChosen = false
Moves.Blocker.Visible = false
TweenService:Create(Moves.Blocker, FastIntroInfo, {TextTransparency = 1}):Play()
TweenService:Create(ConfirmMove, IntroInfo, {Position = UDim2.new(-1, 0,0.2, 0)}):Play()
end)
end
end)
end
elseif Type == "Weapons" then
for i=0, Thing.Value do
if Thing.Value <= 0 then Thing:Destroy() return end
local Template = script.WeaponTemplate:Clone()
Template.Parent = ListOfMoves
Template.Item.Text = Thing.Name
local PhysicalWeapon = Folder_Weapons:WaitForChild(Thing.Name)
if PhysicalWeapon then
local DamageValue = PhysicalWeapon:WaitForChild("Damage")
local DurabilityValue = PhysicalWeapon:WaitForChild("Durability")
Template.Durability.Text = DurabilityValue.Value
Template.Damage.Text = DamageValue.Value
end
Template.Item.Activated:Connect(function()
if not MoveChosen then
MoveChosen = true
TweenService:Create(ConfirmMove, IntroInfo, {Position = UDim2.new(0.3, 0,0.2, 0)}):Play()
Moves.Blocker.Visible = true
TweenService:Create(Moves.Blocker, FastIntroInfo, {TextTransparency = 0.2}):Play()
task.spawn(function()
ActionIdle:Stop()
Humanoid.Jump = true
end)
ConfirmMove.Confirm.Activated:Connect(function()
MoveChosen = true
TweenService:Create(Moves, ActionInfo, {Position = UDim2.new(-1, 0,0.6, 0)}):Play()
TweenService:Create(ConfirmMove, IntroInfo, {Position = UDim2.new(-1, 0,0.2, 0)}):Play()
Folder_Remotes.CastMove:FireServer("Attack", Thing.Name)
local Arena = CurrentArena:FindFirstChildOfClass("Folder")
local ArenaCAM = Arena:WaitForChild("A_Cam")
local PlayerCAM = Arena:WaitForChild("P_Cam")
local EnemyCAM = Arena:WaitForChild("E_Cam")
task.spawn(function()
local T1 = TweenService:Create(Camera, ActionInfo, {CFrame = ArenaCAM.CFrame})
local T2 = TweenService:Create(Camera, ActionInfo, {CFrame = EnemyCAM.CFrame})
local T3 = TweenService:Create(Camera, ActionInfo, {CFrame = PlayerCAM.CFrame})
T1:Play()
T1.Completed:Wait()
T2:Play()
T2.Completed:Wait()
end)
end)
ConfirmMove.Cancel.Activated:Connect(function()
Moves.Blocker.Visible = false
MoveChosen = false
TweenService:Create(Moves.Blocker, FastIntroInfo, {TextTransparency = 1}):Play()
TweenService:Create(ConfirmMove, IntroInfo, {Position = UDim2.new(-1, 0,0.2, 0)}):Play()
end)
end
end)
end
end
end
end
local function StartIntro(IconImage, MusicName)
Icon.Image = "rbxassetid://" .. IconImage
local Music = SoundTrack:FindFirstChild(MusicName)
ChosenMusic = MusicName
script.WooshIn:Play()
TweenService:Create(IntroFrame, LongIntroInfo, {BackgroundTransparency = 0}):Play()
TweenService:Create(Icon, FastIntroInfo, {Size = UDim2.new(0.5, 0,0.7, 0), Rotation = -4, ImageTransparency = 0}):Play()
TweenService:Create(Dark1, IntroInfo, {Position = UDim2.new(-0.1,0,0.5,0)}):Play()
TweenService:Create(Dark2, IntroInfo, {Position = UDim2.new(1.1,0,0.5,0)}):Play()
Music.Playing = true
TweenService:Create(Music, TweenInfo.new(1), {Volume = 0.65}):Play()
task.wait(1.75)
script.WooshOut:Play()
TweenService:Create(IntroFrame, FastIntroInfo, {BackgroundTransparency = 1}):Play()
TweenService:Create(Icon, LongIntroInfo, {Size = UDim2.new(0, 0,0, 0), Rotation = 5, ImageTransparency = 1}):Play()
TweenService:Create(Dark1, FastIntroInfo, {Position = UDim2.new(-2,0,0.5,0)}):Play()
TweenService:Create(Dark2, FastIntroInfo, {Position = UDim2.new(2,0,0.5,0)}):Play()
end
local function CueActions()
TweenService:Create(Moves, LongIntroInfo, {Position = UDim2.new(0.26, 0,0.6, 0)}):Play()
Moves.Blocker.Visible = false
MoveChosen = false
ClearStuff()
end
Folder_Remotes.StartBattle.OnClientEvent:Connect(function(Image, Music, Stat, NPC_Name)
StartIntro(Image, Music)
Folder_Events.MovementConfig:Fire(false)
local NPC_Stats = require(Stat)
local NPC = Folder_Assets.Models.Characters:FindFirstChild(NPC_Name)
local Arena = CurrentArena:FindFirstChildOfClass("Folder")
local ArenaCAM = Arena:WaitForChild("A_Cam")
local PlayerCAM = Arena:WaitForChild("P_Cam")
local EnemyCAM = Arena:WaitForChild("E_Cam")
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = ArenaCAM.CFrame
task.wait(1)
TweenService:Create(ActInfo, ActionInfo, {Position = UDim2.new(0.5,0,0.85, 0)}):Play()
PlayerFrame.PName.Text = Player.DisplayName
PlayerFrame.Level.Text = "LVL . " .. PlayerStats.LVL.Value
PlayerHP.Value.Text = math.floor(Humanoid.Health) .. "/" .. Humanoid.MaxHealth
PlayerHP.Current.Size = UDim2.new(Humanoid.Health / Humanoid.MaxHealth,0,1,0)
--
EnemyFrame.EName.Text = NPC_Stats.NPC_Name
EnemyFrame.Level.Text = "LVL . " .. NPC_Stats.LVL
EnemyHP.Value.Text = math.floor(NPC.Humanoid.Health) .. "/" .. NPC.Humanoid.MaxHealth
EnemyHP.Current.Size = UDim2.new(NPC.Humanoid.Health / NPC.Humanoid.MaxHealth,0,1,0)
local EnemyModel = Arena.Enemies:FindFirstChildOfClass("Model")
local EnemyHum = EnemyModel.Humanoid
local OldPlayerHP = Humanoid.Health
local OldEnemyHP = EnemyHum.Health
Humanoid.Changed:Connect(function()
if Humanoid.Health < OldPlayerHP then
PlayerHP.Value.Text = math.floor(Humanoid.Health) .. "/" .. Humanoid.MaxHealth
TweenService:Create(PlayerHP.Current, HPInfo, {Size = UDim2.new(Humanoid.Health / Humanoid.MaxHealth,0,1,0)}):Play()
end
OldPlayerHP = Humanoid.Health
end)
EnemyHum.Changed:Connect(function()
if EnemyHum.Health < OldEnemyHP then
EnemyHP.Value.Text = math.floor(EnemyHum.Health) .. "/" .. EnemyHum.MaxHealth
TweenService:Create(EnemyHP.Current, HPInfo, {Size = UDim2.new(EnemyHum.Health / EnemyHum.MaxHealth,0,1,0)}):Play()
end
OldEnemyHP = EnemyHum.Health
end)
TweenService:Create(Camera, ActionInfo, {CFrame = PlayerCAM.CFrame}):Play()
DeclareTurn("Players")
CueActions()
ItemsBtn.Activated:Connect(function()
WeaponHelp.Visible = false
ItemHelp.Visible = true
ActionIdle:Stop()
ThinkIdle:Play()
LoadStuff("Items")
Moves.Effect.Effect.Image = "rbxassetid://6794153626"
end)
WeaponsBtn.Activated:Connect(function()
WeaponHelp.Visible = true
ItemHelp.Visible = false
ThinkIdle:Stop()
ActionIdle:Play()
LoadStuff("Weapons")
Moves.Effect.Effect.Image = "rbxassetid://6794259017"
end)
end)
Folder_Remotes.MoveCompleted.OnClientEvent:Connect(function(Move, Team)
if not CurrentArena:FindFirstChildOfClass("Folder") then return end
local Arena = CurrentArena:FindFirstChildOfClass("Folder")
local ArenaCAM = Arena:WaitForChild("A_Cam")
local PlayerCAM = Arena:WaitForChild("P_Cam")
local EnemyCAM = Arena:WaitForChild("E_Cam")
local T1 = TweenService:Create(Camera, ActionInfo, {CFrame = ArenaCAM.CFrame})
local T2 = TweenService:Create(Camera, ActionInfo, {CFrame = EnemyCAM.CFrame})
local T3 = TweenService:Create(Camera, ActionInfo, {CFrame = PlayerCAM.CFrame})
if Move == "Attack" and Team == "Players" then
T1:Play()
T1.Completed:Wait()
T3:Play()
T3.Completed:Wait()
elseif Move == "Attack" and Team == "Enemies" then
DeclareTurn("Players")
ClearStuff()
CueActions()
elseif Move == "Item" and Team == "Players" then
T1:Play()
T1.Completed:Wait()
T3:Play()
T3.Completed:Wait()
end
end)
Folder_Remotes.EnemyTurn.OnClientEvent:Connect(function()
DeclareTurn("Enemies")
Folder_Remotes.EnemyMove:FireServer("Attack")
end)
Folder_Remotes.EndBattle.OnClientEvent:Connect(function()
TransitionModule:TweenIn(1)
local Music = SoundTrack:FindFirstChild(ChosenMusic)
local MusicTween = TweenService:Create(Music, TweenInfo.new(1), {Volume = 0})
Music.TimePosition = 0
MusicTween:Play()
MusicTween.Completed:Wait()
Music.Playing = false
Camera.CameraType = Enum.CameraType.Custom
TweenService:Create(ActInfo, ActionInfo, {Position = UDim2.new(0.5,0,1.5, 0)}):Play()
task.wait(3)
TransitionModule:TweenOut(0.5)
end)
The Attempts I made was doing:
if Thing.Value <= 0 then Thing:Destroy() return end
wait i noticed something… hold on. i may try doing thing.uses.value
EDIT: Nevermind. I don’t think that was the case.