Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NOTE = [=[
- The client script for the Gladiatorial game I'm designing, communicates with the server to perform simple tasks
- ]=]
- wait(1)
- --Services
- local Players = game:GetService('Players');
- local ControllerService = game:GetService('ControllerService');
- local Lighting = game:GetService('Lighting');
- Spectating = true;
- -- Lighting
- local Items = Lighting.Items;
- local Weapons = Items.Weapons;
- -- Workspace
- local SpectatorSpawn = Workspace.SpectatorSpawn;
- local Cam = Workspace.CurrentCamera;
- local PoolCommunication = Workspace:WaitForChild('PoolCommunication');
- local PoolNote = PoolCommunication.Note;
- local Head1,Head2 = PoolCommunication.Head1,PoolCommunication.Head2;
- local InBattle = PoolCommunication.InBattle;
- local Spawn1,Spawn2 = Workspace.Spawn1,Workspace.Spawn2;
- local Exit1,Exit2 = Workspace.Exit1,Workspace.Exit2;
- local Reputation = PoolCommunication.Reputation;
- local Swap = PoolCommunication.Swap;
- -- Player
- local Player = Players.LocalPlayer;
- repeat wait(0) until Player:FindFirstChild('Begin');
- local Begin = Player.Begin;
- local PlayerName = Player.Name;
- -- UI
- local PlayerGui = Player.PlayerGui;
- local Scripts = PlayerGui:WaitForChild('Scripts');
- local MainUI = PlayerGui:WaitForChild('Main');
- local Title = MainUI.Title;
- local Note = MainUI.Note;
- local NoteLabel = Note.TextLabel
- local Slide,Join,Spectate = Title.Slide,Title.Join,Title.Spectate;
- local StatsF = MainUI.Stats;
- local FatigueL,HealthL = StatsF.Fatigue,StatsF.Health;
- local SpectateF = MainUI.Spectate;
- local Char1B,Char2B = SpectateF.Char1,SpectateF.Char2;
- local Mouse = Player:GetMouse();
- Title.Visible = true
- local Stats = Lighting.Stats:Clone(); Stats.Parent = Player;
- local Fatigue = Stats.Fatigue;
- local Health = Stats.Health;
- local MaxHealth = Stats.Health.MaxHealth;
- -- Character
- local Char = Player.Character;
- local Torso = Char.Torso;
- local Human = Char.Humanoid;
- local Head = Char.Head;
- --Other
- local CFrame_fromEulerAnglesXYZ = CFrame.fromEulerAnglesXYZ;
- local math_random = math.random;
- local math_pi = math.pi;
- local Instance_new = Instance.new;
- local coroutine_resume,coroutine_create = coroutine.resume,coroutine.create;
- -- UDim Variables
- local UDim2_new = UDim2.new;
- local TitleOut = UDim2_new(0.25, 0, 0.300000012, 0);
- local TitleIn = UDim2_new(-0.52, 0, 0.300000012, 0);
- local NoteMiddle = UDim2_new(.25, 0, 0.0250000004, 0);
- local NoteOut = UDim2_new(1, 0, 0.0250000004, 0);
- local NoteIn = UDim2_new(-1, 0, 0.0250000004, 0);
- -- CFrame Variables
- local CFrame_new = CFrame.new;
- local SpectateArena = CFrame_new(71.4063721, 217.901276, 612.066406, 0.534695625, 0.11910519, -0.836609006, 7.45057971e-009, 0.990017414, 0.140945449, 0.845044672, -0.0753629208, 0.52935797);
- local SpectateSpawn1 = CFrame_new(91.0122452, 213.525925, 528.652954, 0.161178812, -0.0930062011, 0.982533097, 9.31322575e-010, 0.995549738, 0.0942383409, -0.986925244, -0.015189223, 0.160461515);
- local SpectateSpawn2 = CFrame_new(190.143463, 215.344849, 613.225708, -0.20315595, 0.0812921226, -0.975765944, -0, 0.99654758, 0.0830234587, 0.979146421, 0.01686671, -0.202454552);
- Cam.CameraType = 'Scriptable';
- Cam.CoordinateFrame = SpectateArena;
- -- String Variables
- local Status = 'Inactive';
- local Rep = 'Bad'
- -- Functions
- local function GiveWeapons(txt,b)
- local item = Weapons[txt];
- local weld = Instance_new("Weld")
- obj = item:clone()
- obj.Parent = Workspace --p.Character
- weld.Parent = obj.Handle
- weld.Part0 = Char[item.Slot.Value]
- weld.Part1 = obj.Handle
- weld.C0 = item.OS.Value
- weld.Name = "Pre"
- Scripts[b].Value = obj
- end
- function giveweaponslots()
- local tbs = script.BackSlot:clone()
- tbs.Parent = Char
- local wb = Instance_new("Weld", tbs)
- wb.Part0 = tbs
- tbs.CFrame = Char.Torso.CFrame
- wb.Part1 = Char.Torso
- wb.C0 = CFrame_new(-.45, 0, -.65) * CFrame_fromEulerAnglesXYZ(0, 0, math_pi/12)
- local tbs2 = script.BackSlot:clone()
- tbs2.Parent = Char
- tbs2.Name = "OffSlot"
- local wb2 = Instance_new("Weld", tbs2)
- wb2.Part0 = tbs2
- tbs2.CFrame = Char.Torso.CFrame
- wb2.Part1 = Char.Torso
- wb2.C0 = CFrame_new(.45, 0, -.65) * CFrame_fromEulerAnglesXYZ(0, 0, -math_pi/12)
- local tss = script.SideSlot:clone()
- tss.Parent = Char
- local ws = Instance_new("Weld", tss)
- ws.Part0 = tss
- tss.CFrame = Char["Left Arm"].CFrame
- ws.Part1 = Char.Torso
- ws.C0 = CFrame_new(1.15, .65, .95) * CFrame_fromEulerAnglesXYZ(math_pi/4, 0, 0)
- local b = script.SideSlot:clone()
- b.Parent = Char
- b.Name = "HandSlot"
- local w = Instance_new("Weld", b)
- w.Part0 = Char["Right Arm"]
- w.Part1 = b
- w.C0 = CFrame_new(0,-1.10,0) * CFrame_fromEulerAnglesXYZ(-math_pi/2,0,0)
- local b2 = script.SideSlot:clone()
- b2.Parent = Char
- b2.Name = "HandSlot2"
- local w = Instance_new("Weld", b2)
- w.Part0 = Char["Left Arm"]
- w.Part1 = b2
- w.C0 = CFrame_new(0,-1.10,0) * CFrame_fromEulerAnglesXYZ(-math_pi/2,0,0)
- --[[thairp = hairp:clone()
- thairp.CFrame = head.CFrame
- local hpw = Instance_new("Weld", head)
- hpw.Part0 = head
- hpw.Part1 = thairp
- hpw.C0 = CFrame_new(0,.3,0)
- thairp.Parent = Char]]
- end
- local function LookAtEntrance(Entrance,Head)
- Cam:Interpolate(Entrance,Head.CFrame,2);
- end
- local function TweenIn()
- Title:TweenPosition(TitleIn,'Out','Linear',.1,true,nil)
- end
- local function TweenOut()
- Title:TweenPosition(TitleOut,'Out','Linear',.25,true,nil);
- end
- local function Notify(text)
- coroutine_resume(coroutine_create(function()
- if Tweening then repeat wait(0) until not Tweening end
- NoteLabel.Text = text;
- Tweening = true
- Note:TweenPosition(NoteMiddle,'Out','Linear',.25,true,nil)
- wait(2)
- Note:TweenPosition(NoteOut,'Out','Linear',.5,true,nil)
- wait(.6)
- Note.Position = NoteIn;
- Tweening = nil
- end))
- end
- local function Transmit(text)
- Status = text
- if PoolCommunication:FindFirstChild(PlayerName) then
- PoolCommunication:FindFirstChild(PlayerName):Destroy();
- end
- wait(1)
- local val = Instance_new('StringValue',PoolCommunication);
- val.Name = PlayerName;
- val.Value = text;
- end
- local function SpectateInterpolate()
- Interpolating = true;
- while Interpolating do wait(.1);
- if CamTarget then
- Cam:Interpolate(CFrame_new(CamTarget.Position + -(CamTarget.CFrame.lookVector*20) + Vector3.new(0,8,0)),CamTarget.CFrame,.2)
- end
- end
- end
- local function RegenStats()
- local maxhealth = Health.MaxHealth.Value;
- local maxfatigue = Fatigue.MaxFatigue.Value;
- local healthinc = 1;
- local fatigueinc = 4;
- Regening = true;
- while Regening do
- local healthval = Health.Value;
- local fatigueval = Fatigue.Value;
- Health.Value =
- healthval + healthinc <= maxhealth and healthval + healthinc or healthval;
- Fatigue.Value =
- fatigueval + fatigueinc <= maxfatigue and fatigueval + fatigueinc or fatigueval;
- wait(2)
- end
- end
- -- World Events
- local NoteListener = PoolNote.Changed:connect(function()
- Notify(PoolNote.Value);
- end)
- local function ConnectSpectateListener()
- SpectateListener = InBattle.Changed:connect(function()
- if InBattle.Value == true and Spectating then
- --if Status == 'Inactive' then return end
- TweenIn();
- while Head1.Value == nil do wait(1) Notify('|Error with object value|') end
- LookAtEntrance(SpectateSpawn1,Exit1);
- repeat wait(1) until Swap.Value == true
- LookAtEntrance(SpectateSpawn2,Exit2);
- repeat wait(1) until Swap.Value == false
- CamTarget = Head1.Value and Head1.Value or nil
- SpectateF.Visible = true
- SpectateInterpolate();
- elseif InBattle.Value == false then print('Reseting');
- Torso.CFrame = SpectatorSpawn.CFrame;
- Cam.CameraType = 'Scriptable';
- Cam.CoordinateFrame = SpectateArena;
- wait(1)
- TweenOut();
- end
- end)
- end
- ConnectSpectateListener()
- local BeginListener = Begin.Changed:connect(function()
- Transmit('Spectating');
- if SpectateListener then Spectating = nil end
- if Head == Head2.Value then
- Human.WalkSpeed = 0;
- LookAtEntrance(SpectateSpawn1,Exit1);
- repeat wait(1) until Swap.Value == true
- Human.WalkSpeed = 16;
- end
- local goal;
- local begin = Begin.Value;
- Torso.CFrame = begin.CFrame;
- Cam.CameraType = 'Custom'
- Player.CameraMode = 'LockFirstPerson';
- if begin == Spawn1 then
- goal = Exit1;
- else
- goal = Exit2;
- end
- repeat wait(0) until (Torso.Position-goal.Position).Magnitude < 5
- Reputation.Value = Player.Name..'/'..Rep;
- giveweaponslots();
- GiveWeapons('Rusty Sword','Blade');
- GiveWeapons('Wooden Shield','OffHand')
- Notify('Press E To Unsheath');
- Notify('Z for emotes');
- RegenStats();
- end)
- -- UI Events
- local SlideClick = Slide.MouseButton1Click:connect(function()
- TweenOut();
- end)
- local JoinClick = Join.MouseButton1Click:connect(function()
- TweenIn();
- Notify('Joining pool...');
- Transmit('SpectatingReady');
- end)
- local SpectateClick = Spectate.MouseButton1Click:connect(function()
- TweenIn();
- Notify('Spectating only...')
- Transmit('Spectating');
- end)
- local Char1BC = Char1B.MouseButton1Down:connect(function()
- if Head1.Value then CamTarget = Head1.Value
- end
- end)
- local Char2BC = Char2B.MouseButton1Down:connect(function()
- if Head2.Value then CamTarget = Head2.Value
- end
- end)
- local HealthTxt = 'Health: ';
- local FatigueTxt = 'Fatigue: '
- local UpdateHealth = Health.Changed:connect(function()
- HealthL.Text = HealthTxt..Health.Value;
- end)
- local UpdateFatigue = Fatigue.Changed:connect(function()
- FatigueL.Text = FatigueTxt..Fatigue.Value;
- end)
- FatigueL.Text = HealthTxt..Fatigue.Value;
- HealthL.Text = FatigueTxt..Health.Value;
- Notify(PoolNote.Value);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement