Created
January 18, 2018 22:37
-
-
Save Aerodos12/fcab5e4c461109ddc22bbc83c9859f05 to your computer and use it in GitHub Desktop.
Squad Intro
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local plr = game.Players.LocalPlayer | |
local HUD = script.Parent | |
local chr = plr.Character | |
if not chr or not chr.Parent then | |
chr = plr.CharacterAdded:wait() | |
end | |
local FLOOR = math.floor | |
local Players = game.Players | |
local WFC = game.WaitForChild | |
local ffc = game.FindFirstChild | |
local UD2 = UDim2.new | |
local pGui = plr.PlayerGui | |
local Spot = pGui:WaitForChild("Spot",200) | |
local distance = 300 | |
local CF = CFrame.new | |
local infolder =function(l,e) for i=1,#l do if l[i].Name==e then return l[i] end end end | |
local C3 = Color3.new | |
local cam = workspace.CurrentCamera | |
local GetThumbnail = Players.GetUserThumbnailAsync | |
local ReplicatedStorage = game.ReplicatedStorage | |
local RunService = game:GetService("RunService") | |
local UIS = game:GetService("UserInputService") | |
local RemoteService = require(ReplicatedStorage.RemoteService) | |
local InventoryService = require(ReplicatedStorage.InventoryService) | |
local MarketService = require(ReplicatedStorage.MarketService) | |
local XAdapt = require(ReplicatedStorage.XAdapt) | |
local Starting = require(game.Workspace.Settings.Starting) | |
local PerLevel = require(game.Workspace.Settings.PerLevel) | |
local AttributeEffect = require(game.Workspace.Settings.AttributeEffect) | |
local typelist = require(workspace.Settings.AwardTypes) | |
local RPGM = require(ReplicatedStorage.RPGMathProvider) | |
local CLC = require(HUD.ConfirmLoadoutChange) | |
local CameraManager = require(script.Parent.CameraManager) | |
local Radar = HUD.Radar | |
local RadarUIs = ReplicatedStorage.RadarUIs | |
WFC(plr,"leaderstats",400) | |
local Lvl =WFC( plr.leaderstats,"Lvl",400) | |
local Credits = WFC(plr.leaderstats,"Credits",400) | |
WFC(plr,"Stats",400) | |
local MaxMana = WFC(plr.Stats,"MaxMana",400) | |
local Mana = WFC(plr.Stats,"Mana",400) | |
local hmd = WFC(chr,'Humanoid') | |
local HealthUI = HUD.Base.HealthBar | |
local ManaUI = WFC(HUD.Base,"ManaBar",400) | |
WFC(HUD,"GoldBar",400) | |
local ActionsBar = WFC(HUD,"ActionsBar",200) | |
local StatsUI = HUD.StatTables | |
local GoldUI = WFC(HUD.GoldBar,"GoldBox",400) | |
local CharNameUI = WFC(HUD.Base,"CharName",400) | |
local feedbackMain = HUD.FeedbackMain | |
local NotifyList = HUD.NotifyList | |
local NotifContainer = HUD.NotificationsList | |
local ANotifyList = HUD.AwardNotifyList | |
local LevelUpScreen = HUD.LevelUpContainer | |
local ObjectivesBox = HUD.Objectives | |
local Objectives = ObjectivesBox.Container | |
local TickerModes =script.Parent.TickerMessage.TickerModes | |
local Ticker = script.Parent.TickerMessage | |
local MouseTip = HUD.MouseTip | |
local Mouse = plr:GetMouse() | |
local HBarObj = require(game.ReplicatedStorage.Healthbar) | |
local Levels = { | |
[1] = Color3.new(255/255, 199/255, 134/255), | |
[2] = Color3.new(1,1,1), | |
[3] = Color3.new(255/255, 208/255, 19/255), | |
[4] = Color3.new(.8, .8, .9), | |
} | |
local healthBars = {} | |
local function findHBarIndex(mob) | |
for i, healthbar in pairs(healthBars) do | |
if healthbar.Entity == mob then | |
return i | |
end | |
end | |
return nil | |
end | |
local kills = 0 | |
local function getColor(plr) | |
local color = Color3.new(0,0,0) | |
if plr then | |
if plr:IsA("Player") then | |
color = plr.TeamColor.Color | |
elseif plr:IsA("Model") then | |
color = ((require(plr.BOT).Allegiance == "Good") and BrickColor.Blue().Color or BrickColor.Red().Color) | |
end | |
end | |
return color | |
end | |
local function addToFeed(killer,weaponName,killed) | |
kills = kills + 1 | |
print("Adding kill " .. kills .. " ...") | |
local item = game.ReplicatedStorage.KillFeedUIs.FeedItem:Clone() | |
item.Killer.Text = killer.Name | |
item.Weapon.Text = weaponName | |
item.Killed.Text = killed.Name | |
item.Killer.TextColor3 = getColor(killer) | |
item.Killed.TextColor3 = getColor(killed) | |
--item.Position = | |
item.Parent = HUD.Feed | |
item.Visible = true | |
print(item.Parent.Name) | |
spawn(function() | |
wait(20) | |
for i = 1, 10 do | |
if item.Parent then | |
item.Killer.TextTransparency=i/10 | |
item.Killer.TextStrokeTransparency=i/10+0.5 | |
item.Weapon.TextStrokeTransparency=i/10+0.5 | |
item.Weapon.TextTransparency=i/10 | |
item.Killed.TextStrokeTransparency=i/10+0.5 | |
item.Killed.TextTransparency=i/10 | |
wait(1/30) | |
end | |
end | |
if item and item.Parent then game.Debris:AddItem(item,0.1) end | |
end) | |
local kb=HUD.Feed:GetChildren() | |
for i=1,#kb do | |
local v=kb[i] | |
if v:IsA("Frame") then | |
v:TweenPosition(UDim2.new(0,0,0.2*(#kb-i),0),"Out","Sine",0.2,true) | |
if #kb>5 and (#kb-i)>=5 then | |
spawn(function() | |
if kb[1].Name~="Deleted" then | |
for i = 1, 10 do | |
if game.FindFirstChild(kb[1],"Killed") then | |
kb[1].Killer.TextTransparency=i/10 | |
kb[1].Killer.TextStrokeTransparency=i/10+0.5 | |
kb[1].Killed.TextTransparency=i/10 | |
kb[1].Killed.TextStrokeTransparency=i/10+0.5 | |
kb[1].Name="Deleted" | |
kb[1].Weapon.TextTransparency=i/10 | |
kb[1].Weapon.TextStrokeTransparency=i/10+0.5 | |
wait(1/30) | |
end | |
end | |
game.Debris:AddItem(kb[1],0.1) | |
end | |
end) | |
end | |
end | |
end | |
end | |
local function NotifyAchievement(aw, level) | |
script.Parent.AchievementsFrame.Visible = true | |
script.Parent.AchievementsFrame.TrophyImage.ImageColor3 = Levels[level] | |
script.Parent.AchievementsFrame.AchievementPlate.Text = ("Achievement: "..aw):upper() | |
delay(5, function() | |
script.Parent.AchievementsFrame.Visible = false | |
end) | |
end | |
local function typeout(label,speed) | |
local speed=speed or 2 | |
local text=label.Text | |
label.Text="" | |
for i=1,#text do | |
label.Text=text:sub(1,speed*i) | |
wait(1/60) | |
end | |
end | |
local function queuetypeout(label,speed) | |
local speed=speed or 3 | |
local text=label.Text | |
label.Text="" | |
spawn(function() | |
for i=1,#text do | |
label.Text=text:sub(1,speed*i) | |
wait(1/60) | |
end | |
end) | |
end | |
local function LevelUp(level,creditsPerLevel,newThings) | |
local br = ReplicatedStorage.LevelUpScreen:Clone() | |
local money =br.Money | |
local title =br.Title | |
local rtext =br.Level | |
local count =0 | |
local sht = LevelUpScreen:GetChildren() | |
for i=1,#sht do | |
if sht[i].Name=="RankBar" or sht[i].Name=="AttachBar" then | |
count=count+1 | |
end | |
end | |
br.Parent =LevelUpScreen | |
rtext.Text =level | |
money.Text ="+"..(creditsPerLevel) | |
local RSConn = nil | |
local t0=tick() | |
RSConn = RunService.RenderStepped:connect(function() | |
local t=tick()-t0 | |
--set the transparencies | |
rtext.TextTransparency=t<3 and 0 or t<3.5 and (t-3)/0.5 or 1 | |
title.TextTransparency=t<3 and 0 or t<3.5 and (t-3)/0.5 or 1 | |
money.TextTransparency=t<0.5 and 1 or t<3.5 and 0 or t<4 and (t-3.5)/0.5 or 1 | |
if 4<t then | |
RSConn:Disconnect() | |
br:Destroy() | |
-- if newguns then | |
-- for i=1,#newguns do | |
-- unlockedgun(newguns[i]) | |
-- wait(3)--LELELELLELEELLELELELELE | |
-- end | |
-- end | |
end | |
end) | |
end | |
local function getCorrespondingLoadoutItem(wName) | |
local backpack = plr.Backpack | |
local result | |
for _, item in pairs(backpack:GetChildren()) do | |
if item:IsA("Tool") then | |
if ffc(item,"AmmoProfile") then | |
if item.AmmoProfile.Value == wName then | |
result = item | |
break | |
end | |
end | |
end | |
end | |
if not result then | |
for _, item in pairs(chr:GetChildren()) do | |
if item:IsA("Tool") then | |
if ffc(item,"AmmoProfile") then | |
if item.AmmoProfile.Value == wName then | |
result = item | |
break | |
end | |
end | |
end | |
end | |
end | |
return result | |
end | |
local camAng = 0 | |
local feedbackMaxCharacters = 500 | |
local function getRemainingFeedbackChars() | |
return feedbackMaxCharacters - #feedbackMain.Input.Text | |
end | |
feedbackMain.CharactersLeft.Text = getRemainingFeedbackChars() | |
local function ShowTip(topText,bottomText) | |
MouseTip:TweenSize(UDim2.new(0,250 , 0,125), "Out", "Quad", 0.2) | |
MouseTip.Top.Text = topText | |
MouseTip.Bottom.Text = bottomText | |
RunService:BindToRenderStep("ShowTip",Enum.RenderPriority.Input.Value,function() | |
MouseTip.Position = UDim2.new(0,Mouse.X , 0,Mouse.Y) | |
end) | |
end | |
local function HideTip() | |
RunService:UnbindFromRenderStep("ShowTip") | |
MouseTip:TweenSize(UDim2.new(0,0 , 0,0), "Out", "Quad", 0.2) | |
MouseTip.Position = UDim2.new(0,Mouse.X , 0,Mouse.Y) | |
MouseTip.Top.Text = "topText" | |
MouseTip.Bottom.Text = "bottomText" | |
end | |
function ToggleStats() | |
StatsUI.Visible = not StatsUI.Visible | |
if StatsUI.Visible then | |
CameraManager:cameraSetup(chr) | |
RunService:BindToRenderStep("StatsRotate",Enum.RenderPriority.Camera.Value,function() | |
local t = chr.Torso | |
cam.CoordinateFrame = CFrame.new(t.Position) | |
* CFrame.Angles(0, camAng, 0) | |
* CFrame.new(0, 0, 10) | |
camAng = camAng + math.rad(1) | |
end) | |
else | |
RunService:UnbindFromRenderStep("StatsRotate") | |
CameraManager:cameraReset(chr,16) | |
end | |
end | |
function OpenCreditsShop() | |
MarketService:Prompt("credits",plr) | |
end | |
function ToggleArmor() | |
HUD.Armor.Visible = not HUD.Armor.Visible | |
end | |
local XScheme = XAdapt:CreateSelectionScheme("ActionsBar",1,0.98) | |
local feedbackOpen = false | |
local db = false | |
local inRed = false | |
local RadarClient = {} | |
RadarClient.Dots = { | |
["Player"] = {}; | |
["Mob"] = {}; | |
["Squadmate"] = {}; | |
["Fighter"]= {}; | |
["Ammo"]= {}; | |
}; | |
function RadarClient:AddDot(entityType,entity) | |
local dot | |
if entityType == "Fighter" then | |
dot =RadarUIs.Fighter:Clone() | |
elseif entityType == "Ammo" then | |
dot =RadarUIs.Ammo:Clone() | |
else | |
dot =RadarUIs.Dot:Clone() | |
end | |
dot.Entity.Value = entity | |
if entityType ~= "Ammo" then | |
dot.Parent= Radar.RadarSlots:FindFirstChild(entityType .. "s") | |
else | |
dot.Parent = Radar.RadarSlots:FindFirstChild(entityType) | |
end | |
dot.Visible=false | |
RadarClient.Dots[entityType][#RadarClient.Dots[entityType]+1]=dot | |
return dot, #RadarClient.Dots[entityType] | |
end | |
function RadarClient:GetDot(entity,entityType) | |
local result = nil | |
local dots | |
if entityType ~= "Ammo" then | |
dots = Radar.RadarSlots:FindFirstChild(entityType .. "s"):GetChildren() | |
else | |
dots = Radar.RadarSlots:FindFirstChild(entityType):GetChildren() | |
end | |
for i = 1,#dots do | |
local v = dots[i] | |
if v.Entity.Value then | |
if v.Entity.Value == entity then | |
result = v | |
end | |
end | |
end | |
return result | |
end | |
function RadarClient:UpdatePosition(entityType, ref,pos,color,trans) | |
local dot=RadarClient.Dots[entityType][ref] | |
if not dot then return end | |
dot.Visible=true | |
dot.BackgroundColor3=color | |
dot.Position=pos | |
if dot:IsA("Frame") then | |
dot.BackgroundTransparency=trans | |
elseif dot:IsA("ImageLabel") then | |
dot.BackgroundTransparency=1 | |
dot.ImageTransparency=trans | |
elseif dot:IsA("TextLabel") then | |
dot.BackgroundTransparency=1 | |
dot.TextTransparency=trans | |
end | |
end | |
RadarClient.Entities = { | |
["Player"] = function() | |
local old = Radar.RadarSlots.Players:GetChildren() | |
for i =1, #old do | |
old[i].Visible=false | |
end | |
local torso = chr.Torso | |
local look = torso.CFrame.lookVector | |
local cameraCF = CF(torso.CFrame.p,torso.CFrame.p + look) | |
local entities = game.Players:GetPlayers() | |
for i = 1,#entities do | |
local v = entities[i] | |
if v ~= plr and v.Character and workspace:FindFirstChild(v.Name) then | |
local tor = ffc(v.Character,"Torso") | |
local alive = ffc(v.Character,"Humanoid") | |
if tor and alive then | |
local allegianceLoc = plr.Allegiance | |
local diff = cameraCF:inverse()*tor.Position | |
local x = 0.5+diff.x/distance | |
local y = 0.5+diff.z/distance | |
local pos = UD2(x,0,y,0) | |
local color = ((allegianceLoc.Value == plr.Allegiance.Value) and C3(48, 255, 12) or C3(255,0,0)) | |
if RadarClient:GetDot(v,"Player") then | |
RadarClient:UpdatePosition("Player",i,pos,color,-0.5+(torso.Position-tor.Position).Magnitude/150) | |
else | |
local dot, i2 = RadarClient:AddDot("Player",v) | |
RadarClient:UpdatePosition("Player",i2,pos,color,-0.5+(torso.Position-tor.Position).Magnitude/150) | |
end | |
end | |
end | |
end | |
end; | |
["Mob"] = function() | |
local old = Radar.RadarSlots.Mobs:GetChildren() | |
for i =1, #old do | |
old[i].Visible=false | |
end | |
local torso = chr.Torso | |
local look = torso.CFrame.lookVector | |
local cameraCF = CF(torso.CFrame.p,torso.CFrame.p + look) | |
local entities = workspace.Mobs:GetChildren() | |
for i = 1,#entities do | |
local v = entities[i] | |
local tor = ffc(v,"Torso") | |
local alive = ffc(v,"Human") | |
if tor and alive then | |
local allegianceLoc = require(v.BOT) | |
local diff = cameraCF:inverse()*tor.Position | |
local x = 0.5+diff.x/distance | |
local y = 0.5+diff.z/distance | |
local pos = UD2(x,0,y,0) | |
local color = ((allegianceLoc.Allegiance == plr.Allegiance.Value) and C3(48, 255, 12) or C3(255,0,0)) | |
if RadarClient:GetDot(v,"Mob") then | |
RadarClient:UpdatePosition("Mob",i,pos,color,-0.5+(torso.Position-tor.Position).Magnitude/150) | |
else | |
local dot, i2 = RadarClient:AddDot("Mob",v) | |
RadarClient:UpdatePosition("Mob",i2,pos,color,-0.5+(torso.Position-tor.Position).Magnitude/150) | |
end | |
end | |
end | |
end; | |
["Squadmate"] = function() | |
local old = Radar.RadarSlots.Squadmates:GetChildren() | |
for i =1, #old do | |
old[i].Visible=false | |
end | |
local torso = chr.Torso | |
local look = torso.CFrame.lookVector | |
local cameraCF = CF(torso.CFrame.p,torso.CFrame.p + look) | |
local entities = plr.playerArmy.Value:GetChildren() | |
for i = 1,#entities do | |
local v = entities[i] | |
local tor = ffc(v,"Torso") | |
local alive = ffc(v,"Human") | |
if tor and alive then | |
local allegianceLoc = require(v.BOT) | |
local diff = cameraCF:inverse()*tor.Position | |
local x = 0.5+diff.x/distance | |
local y = 0.5+diff.z/distance | |
local pos = UD2(x,0,y,0) | |
local color = ((allegianceLoc.Allegiance == plr.Allegiance.Value) and C3(48, 255, 12) or C3(255,0,0)) | |
if RadarClient:GetDot(v,"Squadmate") then | |
RadarClient:UpdatePosition("Squadmate",i,pos,color,-0.5+(torso.Position-tor.Position).Magnitude/150) | |
else | |
local dot, i2 = RadarClient:AddDot("Squadmate",v) | |
RadarClient:UpdatePosition("Squadmate",i2,pos,color,-0.5+(torso.Position-tor.Position).Magnitude/150) | |
end | |
end | |
end | |
end; | |
["Fighter"] = function() | |
local old = Radar.RadarSlots.Squadmates:GetChildren() | |
for i =1, #old do | |
old[i].Visible=false | |
end | |
local torso = chr.Torso | |
local look = torso.CFrame.lookVector | |
local cameraCF = CF(torso.CFrame.p,torso.CFrame.p + look) | |
local entities = workspace.Fighters.Evil:GetChildren() | |
for _, entity in pairs(workspace.Fighters.Good:GetChildren()) do | |
if entity then | |
entities[#entities+1] = entity | |
end | |
end | |
for i = 1,#entities do | |
local v = entities[i] | |
local alive = ffc(v,"Human",true) | |
if alive then | |
local allegianceLoc = require(alive.Parent.BOT) | |
if not alive.Parent:FindFirstChild("Torso") or not v.PrimaryPart then return end | |
local diff = cameraCF:inverse()*alive.Parent.Torso.Position | |
local x = 0.5+diff.x/distance | |
local y = 0.5+diff.z/distance | |
local pos = UD2(x,0,y,0) | |
local color = ((allegianceLoc.Allegiance == plr.Allegiance.Value) and C3(48, 255, 12) or C3(255,0,0)) | |
if RadarClient:GetDot(v,"Fighter") then | |
RadarClient:UpdatePosition("Fighter",i,pos,color,-0.5+(torso.Position-v.PrimaryPart.Position).Magnitude/150) | |
else | |
local dot, i2 = RadarClient:AddDot("Fighter",v) | |
RadarClient:UpdatePosition("Fighter",i2,pos,color,-0.5+(torso.Position-v.PrimaryPart.Position).Magnitude/150) | |
end | |
end | |
end | |
end; | |
["Ammo"] = function() | |
local old = Radar.RadarSlots.Ammo:GetChildren() | |
for i =1, #old do | |
old[i].Visible=false | |
end | |
local torso = chr.Torso | |
local look = torso.CFrame.lookVector | |
local cameraCF = CF(torso.CFrame.p,torso.CFrame.p + look) | |
local entities = workspace.Loot.Ammo:GetChildren() | |
for i = 1,#entities do | |
local v = entities[i] | |
if v then | |
local primaryPos = Vector3.new() | |
if v:IsA("Model") then | |
primaryPos = v.PrimaryPart.CFrame.p | |
elseif v:IsA("BasePart") then | |
primaryPos = v.CFrame.p | |
end | |
local diff = cameraCF:inverse()*primaryPos | |
local x = 0.5+diff.x/distance | |
local y = 0.5+diff.z/distance | |
local pos = UD2(x,0,y,0) | |
local color = C3(48, 255, 12) | |
if RadarClient:GetDot(v,"Ammo") then | |
RadarClient:UpdatePosition("Ammo",i,pos,color,-0.5+(torso.Position-primaryPos).Magnitude/150) | |
else | |
local dot, i2 = RadarClient:AddDot("Ammo",v) | |
RadarClient:UpdatePosition("Ammo",i2,pos,color,-0.5+(torso.Position-primaryPos).Magnitude/150) | |
end | |
end | |
end | |
end; | |
} | |
function RadarClient:Spot(entity) | |
local prev=infolder(Spot:GetChildren(),entity.Name) | |
if prev then | |
prev.Time.Value=(prev.Time.Value<=30 and 30) or (prev.Time.Value+30>200 and 200) or prev.Time.Value+30 | |
else | |
local mark=RadarUIs.Spot:Clone() | |
mark.Parent=Spot | |
mark.Name=entity.Name | |
mark.Time.Value=30 | |
mark.Adornee=chr.Head | |
end | |
end | |
function RadarClient:Reload() | |
for _, entityTypeFunc in pairs(RadarClient.Entities) do | |
entityTypeFunc() | |
end | |
end | |
function sendResponse() | |
db = true | |
local msg = feedbackMain.Input.Text | |
feedbackMain.Input.Text = "Sending Message..." | |
local response = RemoteService.fetch("Server","SendFeedback",msg) | |
feedbackMain.Input.Text = response | |
wait(5) | |
if feedbackMain.Input.Text == response then | |
feedbackMain.Input.Text = "Type feedback/bug report here" | |
end | |
db = false | |
end | |
local function unlockedpower(powerName,xpPayout) | |
local br =ReplicatedStorage.ForcePowerBar:Clone() | |
local title =br.Title | |
local atext =br.Power | |
local xpText = br.XP | |
br.Parent =script.Parent.ForcePowerList | |
atext.Text = powerName | |
xpText.Text = "[+" .. xpPayout .. "]" | |
local RSConn = nil | |
local t0=tick() | |
RSConn = RunService.RenderStepped:connect(function() | |
local t=tick()-t0 | |
--set the transparencies | |
atext.TextTransparency=t<2 and 0 or t<2.5 and (t-2)/0.5 or 1 | |
title.TextTransparency=t<2 and 0 or t<2.5 and (t-2)/0.5 or 1 | |
xpText.TextTransparency =t<2 and 0 or t<2.5 and (t-2)/0.5 or 1 | |
atext.TextStrokeTransparency = atext.TextTransparency | |
title.TextStrokeTransparency = title.TextTransparency | |
xpText.TextStrokeTransparency = xpText.TextTransparency | |
if 3<t then | |
br:Destroy() | |
RSConn:Disconnect() | |
RemoteService.send("Server","ForcePowerUpgradeCompleted") | |
end | |
end) | |
end | |
function update(stat) | |
if stat == "Health" then | |
local percent = hmd.Health / hmd.MaxHealth | |
HealthUI.Fill:TweenSize(UD2(percent, 0, 1, 0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.2) | |
inRed = (percent <= 0.25) | |
if inRed then | |
HealthUI.Fill.BackgroundColor3 = Color3.fromRGB(255, 0, 0) | |
else | |
HealthUI.Fill.BackgroundColor3 = Color3.fromRGB(25, 25, 25) | |
end | |
elseif stat == "Mana" then | |
local percent = Mana.Value / MaxMana.Value | |
ManaUI.Fill:TweenSize(UD2(percent, 0, 1, 0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.2) | |
elseif stat == "Credits" then | |
GoldUI.Text = Credits.Value | |
elseif stat == "Name" then | |
CharNameUI.Text = plr.Name | |
elseif stat == "Avatar" then | |
local img, loaded = GetThumbnail(Players,plr.UserId,Enum.ThumbnailType.HeadShot,Enum.ThumbnailSize.Size420x420) | |
HUD.Base.CharacterIcon.Image = (loaded and img or "") | |
elseif stat == "Feedback" then | |
feedbackMain.CharactersLeft.Text = getRemainingFeedbackChars() | |
feedbackMain.CharactersLeft.TextColor3 = ((getRemainingFeedbackChars() < 0) and Color3.fromRGB(255,50,50) or Color3.fromRGB(255,255,255)) | |
end | |
end | |
local pickupSteps = { | |
[1] = function() | |
local itemdrop=workspace.Loot | |
local stuff=itemdrop:GetChildren() | |
local dist=8 | |
local diff = 8 | |
local model | |
for i=1,#stuff do | |
local v=stuff[i] | |
if v:IsA("Model") and v.PrimaryPart then | |
diff=(v:GetPrimaryPartCFrame().p-chr.HumanoidRootPart.Position).magnitude | |
elseif v:IsA("BasePart") then | |
diff=(v.Position-chr.HumanoidRootPart.Position).magnitude | |
end | |
if diff<dist then | |
dist = diff | |
model = v | |
end | |
end | |
if model then | |
local item = ReplicatedStorage.ITEMS:FindFirstChild(model.Name,true) | |
local confirmation | |
local slot | |
if item.Type.Value == "Blaster" then | |
if InventoryService.WeaponSet.IsRifle(item.BlasterType.Value) then | |
slot = "PRIMARY" | |
elseif InventoryService.WeaponSet.IsPistol(item.BlasterType.Value) then | |
slot = "SECONDARY" | |
end | |
elseif item.Type.Value == "Launcher" then | |
slot = "EXPLOSIVE" | |
elseif item.Type.Value == "Medpack" then | |
slot = "GADGET" | |
elseif item.Type.Value == "Saber" or item.Type.Value == "Blade" then | |
slot = "MELEE" | |
end | |
confirmation = CLC(slot) | |
if confirmation then | |
RemoteService.send("Server","AddItemToLoadout",slot,item.Name) | |
end | |
end | |
end; | |
[2] = function() | |
local itemdrop=workspace.Loot.Ammo | |
local stuff=itemdrop:GetChildren() | |
local dist=8 | |
local diff = 8 | |
local model | |
for i=1,#stuff do | |
local v=stuff[i] | |
if v:IsA("Model") and v.PrimaryPart then | |
diff=(v:GetPrimaryPartCFrame().p-chr.HumanoidRootPart.Position).magnitude | |
elseif v:IsA("BasePart") then | |
diff=(v.Position-chr.HumanoidRootPart.Position).magnitude | |
end | |
if diff<dist then | |
dist = diff | |
model = v | |
end | |
end | |
if model then | |
local weaponMagStats, weaponName | |
if model:IsA("BasePart") then | |
weaponMagStats, weaponName = require(model.MagStats) | |
elseif model:IsA("Model") then | |
weaponMagStats, weaponName = require(model.MagStats) | |
end | |
local item = getCorrespondingLoadoutItem(weaponMagStats.Title) | |
if item then | |
if item.Type.Value == "Blaster" then | |
if ffc(item,"ReloadLocal") then | |
item.ReloadLocal:Fire(weaponMagStats.Count,weaponMagStats.Capacity) | |
RemoteService.send("Server","DestroyMag",model) | |
end | |
end | |
end | |
end | |
end; | |
} | |
local PickupDisplayFuncs = { | |
[1] = function() | |
local itemdrop=workspace.Loot | |
local stuff=itemdrop:GetChildren() | |
local dist=8 | |
local diff = 8 | |
local model | |
for i=1,#stuff do | |
local v=stuff[i] | |
if v:IsA("Model") and v.PrimaryPart then | |
diff=(v:GetPrimaryPartCFrame().p-chr.HumanoidRootPart.Position).magnitude | |
elseif v:IsA("BasePart") then | |
diff=(v.Position-chr.HumanoidRootPart.Position).magnitude | |
end | |
if diff<dist then | |
dist = diff | |
model = v | |
end | |
end | |
if model then | |
local item = model.Name | |
HUD.Interact.Text = (UIS:GetGamepadConnected(Enum.UserInputType.Gamepad1) and "L2" or "E") .. "TO PICKUP " .. model.Name:upper() | |
else | |
HUD.Interact.Text = ""; | |
end | |
end; | |
[2] = function() | |
local itemdrop=workspace.Loot.Ammo | |
local stuff=itemdrop:GetChildren() | |
local dist=8 | |
local diff = 8 | |
local model | |
for i=1,#stuff do | |
local v=stuff[i] | |
if v:IsA("Model") and v.PrimaryPart then | |
diff=(v:GetPrimaryPartCFrame().p-chr.HumanoidRootPart.Position).magnitude | |
elseif v:IsA("BasePart") then | |
diff=(v.Position-chr.HumanoidRootPart.Position).magnitude | |
end | |
if diff<dist then | |
dist = diff | |
model = v | |
end | |
end | |
if model then | |
local name | |
if model:IsA("BasePart") then | |
_, name = require(model.MagStats) | |
elseif model:IsA("Model") then | |
_, name = require(model.PrimaryPart.MagStats) | |
end | |
HUD.Interact.Text = (UIS:GetGamepadConnected(Enum.UserInputType.Gamepad1) and "L2" or "E") .. "TO RELOAD " .. name:upper() | |
else | |
HUD.Interact.Text = ""; | |
end | |
end; | |
} | |
if hmd then | |
update("Health") | |
update("Mana") | |
print("Loaded ForcePoints: "..tostring(Mana.Value)) | |
update("Credits") | |
update("Name") | |
update("Avatar") | |
update("Feedback") | |
hmd.HealthChanged:connect(function() | |
update("Health") | |
end) | |
Mana.Changed:connect(function() | |
update("Mana") | |
end) | |
RemoteService.listen("Client","Send","UpdateCurrency",function(amount) | |
if amount and amount >= 0 then | |
GoldUI.Text = tostring(amount) | |
else | |
GoldUI.Text = "error" | |
end | |
end) | |
feedbackMain.SendButton.MouseButton1Click:connect(function() | |
if not db and getRemainingFeedbackChars() >= 0 then | |
sendResponse() | |
end | |
end) | |
feedbackMain.Input.Changed:Connect(function() | |
update("Feedback") | |
end) | |
HUD.ActionsBar.Feedback.MouseButton1Click:Connect(function() | |
feedbackOpen = not feedbackOpen | |
if feedbackOpen then | |
feedbackMain:TweenPosition(UD2(1,-300,1,-300),"Out","Quint",0.3,true) | |
else | |
feedbackMain:TweenPosition(UD2(1,100,1,-300),"Out","Quint",0.3,true) | |
end | |
end) | |
RemoteService.listen("Client","Send","DisplayReward",function(amount,rewardType) | |
NotifyList:FindFirstChild(rewardType).Text = "+"..amount.." "..rewardType:upper() | |
NotifyList:FindFirstChild(rewardType).Visible = true | |
wait(5) | |
NotifyList:FindFirstChild(rewardType).Text = "+0 "..rewardType:upper() | |
NotifyList:FindFirstChild(rewardType).Visible = false | |
end) | |
RemoteService.listen("Client","Send","DisplayAward",function(amount,reason) | |
if not amount then return end | |
local AwardFrame = ReplicatedStorage.XPAwardFrame:Clone() | |
local Primary = WFC(AwardFrame,"Primary",200) | |
local Point = WFC(AwardFrame,"Point",200) | |
local fr=ANotifyList:GetChildren() | |
for i=1,#fr do | |
local v=fr[i] | |
if v:IsA("Frame") and v.Parent then | |
v:TweenPosition(UD2(0,0,0.6 - ((#fr-i)*0.15),0),"Out","Sine",0.05,true) | |
end | |
end | |
AwardFrame.Position = UD2(0,0,0.75,0) | |
AwardFrame.Parent = ANotifyList | |
spawn(function() | |
Point.Text="[+"..amount.."]" | |
Primary.Text= typelist[reason] | |
Point.TextTransparency=0 | |
Primary.TextTransparency=0 | |
---animation start | |
typeout(Point,3) | |
typeout(Primary,3) | |
---co-running animations | |
wait(5.5) | |
for i=1,10 do | |
Point.TextTransparency=i/10 | |
Primary.TextTransparency=i/10 | |
Point.TextStrokeTransparency=i/10+0.4 | |
Primary.TextStrokeTransparency=i/10+0.4 | |
wait(1/60) | |
end | |
wait(0.1) | |
AwardFrame:Destroy() | |
end) | |
end) | |
RemoteService.listen("Client","Send","DisplayObjectives",function(objectives) | |
print("Received " .. #objectives .. " Objectives") | |
for _, objective in pairs(Objectives:GetChildren()) do | |
if objective:IsA("TextLabel") then | |
objective:Destroy() | |
end | |
end | |
for _, objective in pairs(objectives) do | |
local ObjectiveButton = game.ReplicatedStorage.QuestGuis.QuestObjective:Clone() | |
ObjectiveButton.Name = objective.Name | |
ObjectiveButton.Text = objective.Text | |
ObjectiveButton.Done.Visible = objective.Completed | |
ObjectiveButton.Parent = Objectives | |
end | |
end) | |
RemoteService.listen("Client","Send","CompleteObjective",function(name) | |
local Objective = Objectives:FindFirstChild(name) | |
if Objective then | |
Objective.Done.Visible = true | |
end | |
end) | |
ObjectivesBox.Toggle.MouseButton1Click:connect(function() | |
if Objectives.Visible then | |
Objectives.Visible = false | |
ObjectivesBox.Title.Visible = false | |
ObjectivesBox.Toggle:TweenPosition(UD2(0, 0, 0, 0),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,1) | |
else | |
ObjectivesBox.Toggle:TweenPosition(UD2(0, 0, 1, 10),Enum.EasingDirection.Out,Enum.EasingStyle.Quad,1) | |
Objectives.Visible = true | |
ObjectivesBox.Title.Visible = true | |
end | |
end) | |
RemoteService.listen("Client","Send","NotifyAchievement",NotifyAchievement) | |
RemoteService.listen("Client","Send","SendNotif",function(notifType) | |
for i = 1,#NotifContainer:GetChildren() do | |
local notif = NotifContainer:GetChildren()[i] | |
if notif:IsA("Frame") then | |
if notif.Position.Y.Scale <= 0 and notif.Position.Y.Offset <= 0 then | |
notif:Destroy() | |
end | |
if notif then | |
notif:TweenPosition(UDim2.new(0,0,0.5 - (0.25 * (#NotifContainer:GetChildren() - i)),0),Enum.EasingDirection.In,Enum.EasingStyle.Quad,0.2) | |
end | |
end | |
end | |
local notif = game.ReplicatedStorage.NotificationUIs:FindFirstChild(notifType):Clone() | |
notif.Position = UDim2.new(0,0,0.75,0) | |
notif.Parent = NotifContainer | |
spawn(function() | |
wait(5.5) | |
for i=1,10 do | |
notif.BackgroundTransparency = i/10 | |
wait(1/60) | |
end | |
wait(0.1) | |
notif:Destroy() | |
end) | |
end) | |
RemoteService.listen("Client","Send","LevelUp",LevelUp) | |
RemoteService.listen("Client","Send","NotifyForcePowerUnlocked",unlockedpower) | |
RemoteService.listen("Client","Bounce","AddToKillFeed",addToFeed) | |
UIS.InputBegan:connect(function(input) | |
if input.UserInputType == Enum.UserInputType.Keyboard then | |
if input.KeyCode == Enum.KeyCode.E then | |
if plr.i8Mode.Value == "Basic" then | |
elseif plr.i8Mode.Value == "Loadout" then | |
for _, func in pairs(pickupSteps) do | |
func() | |
end | |
end | |
end | |
elseif input.UserInputType.Name:find("Gamepad") then | |
end | |
end) | |
RunService:BindToRenderStep("ShowPickup",Enum.RenderPriority.Input.Value,function() | |
for _, func in pairs(PickupDisplayFuncs) do | |
func() | |
end | |
end) | |
for i, mob in pairs(workspace.Mobs:GetChildren()) do | |
healthBars[i] = HBarObj.new(mob,mob.Name,HUD.HealthbarView) | |
healthBars[i]:Setup() | |
end | |
workspace.Mobs.ChildAdded:connect(function(child) | |
healthBars[#healthBars+1] = HBarObj.new(child,child.Name) | |
healthBars[#healthBars]:Setup() | |
end) | |
workspace.Mobs.ChildRemoved:connect(function(child) | |
local i = findHBarIndex(child) | |
if i then | |
healthBars[i]:Destroy() | |
healthBars[i] = nil | |
end | |
end) | |
RunService:BindToRenderStep("Radar",Enum.RenderPriority.Camera.Value,function() | |
RadarClient:Reload() | |
end) | |
XScheme:AddObject(ActionsBar.OpenArmor) | |
XScheme:AddObject(ActionsBar.OpenStats) | |
XScheme:AddObject(ActionsBar.OpenCashStore) | |
XScheme:AddObject(ActionsBar.Feedback) | |
XScheme:MapPreset(2,"Right",1) | |
XScheme:MapPreset(1,"Right",3) | |
XScheme:MapPreset(3,"Right",4) | |
XScheme:MapPreset(4,"Right",2) | |
XScheme:MapPreset(1,"Left",2) | |
XScheme:MapPreset(3,"Left",1) | |
XScheme:MapPreset(4,"Left",3) | |
XScheme:MapPreset(2,"Left",4) | |
XScheme:Register() | |
XScheme:AddInput(Enum.KeyCode.ButtonB,function(xscheme) | |
xscheme:Deselect() | |
end) | |
XScheme:AddInput(Enum.KeyCode.ButtonSelect,function(xscheme) | |
xscheme:Select() | |
end) | |
ActionsBar.OpenCashStore.MouseButton1Click:connect(function() | |
OpenCreditsShop() | |
XScheme:Deselect() | |
end) | |
ActionsBar.OpenStats.MouseButton1Click:connect(function() | |
ToggleStats() | |
if StatsUI.Visible then | |
XScheme:Deselect() | |
end | |
end) | |
ActionsBar.OpenArmor.MouseButton1Click:connect(function() | |
ToggleArmor() | |
if HUD.Armor.Visible then | |
XScheme:Deselect() | |
end | |
end) | |
XScheme:StartInput() | |
hmd.Died:connect(function() | |
RunService:UnbindFromRenderStep("ShowPickup") | |
RunService:UnbindFromRenderStep("Radar") | |
RunService:UnbindFromRenderStep("RenderHealthBars") | |
XScheme:Deselect() | |
XScheme:EndInput() | |
end) | |
HUD.MessageMode.Changed:connect(function(value) | |
for _, v in pairs(TickerModes:GetChildren()) do | |
if v.Name ~= value.."Mode" then | |
v.Disabled = true | |
end | |
end | |
TickerModes[value.."Mode"].Disabled = false | |
end) | |
RemoteService.listen("Client","Send","ChangeMessageMode",function(mode) | |
script.Parent.MessageMode.Value = mode | |
end) | |
RemoteService.listen("Client","Send","ChangeTicker",function(text) | |
Ticker.Text = text | |
end) | |
RemoteService.listen("Client","Send","ShowTip",ShowTip) | |
RemoteService.listen("Client","Send","HideTip",HideTip) | |
end | |
--Player.UIStats.GamepadMode.Changed:connect(function(value) | |
-- | |
-- game.GuiService.SelectedObject =(value == 4 and GUI.ActionsBar.OpenCashStore or nil) | |
--end) | |
-- HBs[player.UserId] = Healthbar.new(player,titles[player.Team.Name][player.iTitle.Title.Value]) | |
-- HBs[player.UserId]:Setup() | |
-- HBs[player.UserId]:UpdateName(player.CharacterName.Value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local player = game.Players.LocalPlayer | |
local Soldiers = { | |
["Good"] = game.ReplicatedStorage.StarterRebel; | |
["Evil"] = game.ReplicatedStorage.StarterTrooper; | |
} | |
local SFUMSSettings = require(game.Workspace.Settings.UnitManagement) | |
local UnitPrices = require(game.ReplicatedStorage.UnitPrices) | |
player:WaitForChild("Allegiance",200) | |
script.Parent.Steps.Entry:Fire() | |
local StagePart = player.CustomizationSlot.Value.ViewPart | |
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable | |
game.Workspace.CurrentCamera.CameraSubject = StagePart | |
game.Workspace.CurrentCamera.CFrame = StagePart.CFrame | |
game.Workspace.CurrentCamera.Focus = CFrame.new(StagePart.CFrame.p,StagePart.CFrame.p + StagePart.CFrame.lookVector):inverse() | |
game.Workspace.CurrentCamera.FieldOfView = 30 | |
local handler = require(game.ReplicatedStorage.Module3D) | |
game.ReplicatedStorage.StartNewSquadMember.OnClientEvent:connect(function(squadMember) | |
local activeModel = handler:Attach3D(script.Parent.Soldier,squadMember,nil,true) | |
activeModel:SetActive(true) | |
game.ReplicatedStorage.RigSquadMember:FireServer(squadMember,player.CustomizationSlot.Value.StandPoint.CFrame + Vector3.new(-2,0,0)) | |
script.Parent.SoldierProperties.SoldierData.SoldierModel.Value = squadMember | |
script.Parent.SoldierProperties.SoldierData.UnitType.Value = SFUMSSettings.DefaultUnits[player.Allegiance.Value] | |
local unitTypeData = UnitPrices[player.Allegiance.Value][script.Parent.SoldierProperties.SoldierData.UnitType.Value] | |
script.Parent.SoldierProperties.SoldierData.SoldierModel.Value.Pants.PantsTemplate = unitTypeData.Clothes.Pants | |
script.Parent.SoldierProperties.SoldierData.SoldierModel.Value.Shirt.ShirtTemplate = unitTypeData.Clothes.Shirt | |
script.Parent.SoldierProperties.SoldierData.Cost.Value = unitTypeData.Cost | |
activeModel:End() | |
game.ReplicatedStorage.RigSquadMember:FireServer(squadMember,player.CustomizationSlot.Value.StandPoint.CFrame) | |
_G.ActiveTrooper = squadMember | |
end) | |
script.Parent.CreateNewUnit.Event:connect(function() | |
game.ReplicatedStorage.StartNewSquadMember:FireServer() | |
script.Parent.SoldierProperties.SoldierData.UnitType.Value = SFUMSSettings.DefaultUnits[player.Allegiance.Value] | |
local unitTypeData = UnitPrices[player.Allegiance.Value][script.Parent.SoldierProperties.SoldierData.UnitType.Value] | |
script.Parent.SoldierProperties.SoldierData.SoldierModel.Value.Pants.PantsTemplate = unitTypeData.Clothes.Pants | |
script.Parent.SoldierProperties.SoldierData.SoldierModel.Value.Shirt.ShirtTemplate = unitTypeData.Clothes.Shirt | |
script.Parent.SoldierProperties.SoldierData.UnitHelmetType.Value = "None" | |
script.Parent.SoldierProperties.SoldierData.Cost.Value = unitTypeData.Cost | |
script.Parent.SoldierProperties.SoldierData.UnitWeaponType.Value = unitTypeData.Weapons[unitTypeData.DefaultWeapon].Name; | |
script.Parent.Steps.Entry:Fire() | |
end) | |
game.ReplicatedStorage.StartNewSquadMember:FireServer() | |
--script.Parent.Properties.SoldierToCustomize.Value = activeModel.Object3D | |
--script.Parent.Parent.Parent.BackgroundTransparency = 1 | |
--script.Parent.Parent.Parent.Parent.StartedCharCustomization:Fire() | |
--player.CharacterAdded:wait() | |
--activeModel:End() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Steps = script.Parent.Parent.Parent.Parent.Steps | |
local SoldierData = script.Parent.Parent.Parent.SoldierData | |
local Entry = Steps.HelmetChosen | |
local Module3D = require(game.ReplicatedStorage.Module3D) | |
local Weapons = {} | |
local Connections = {} | |
local player = game.Players.LocalPlayer | |
player:WaitForChild("Allegiance",200) | |
local function insertWeapon(name,weapon,UI3D) | |
table.insert(Weapons,{ | |
Name = name; | |
weaponModel = weapon; | |
UI = UI3D; | |
}) | |
end | |
local function getWeaponByName(name) | |
local result = nil | |
for _, weapon in pairs(Weapons) do | |
if name == weapon.Name then | |
result = weapon | |
break | |
end | |
end | |
return result | |
end | |
local UnitOptions = require(game.ReplicatedStorage.UnitPrices) | |
Entry.Event:connect(function(unitType) | |
if UnitOptions then | |
for i, unitTypeData in pairs(UnitOptions[player.Allegiance.Value][unitType].Weapons) do | |
local WeaponUI = game.ReplicatedStorage.SquadCustomizationUIs.Weapon:Clone() | |
WeaponUI.Name = unitTypeData.Name | |
insertWeapon(WeaponUI.Name,unitTypeData,Module3D:Attach3D(WeaponUI,unitTypeData)) | |
WeaponUI.Parent = script.Parent.Weapons.WeaponContainer | |
end | |
for _, weapon in pairs(Weapons) do | |
weapon.UI:SetActive(true) | |
weapon.UI:SetCFrame(CFrame.Angles(0,math.rad(-90),0)) | |
end | |
table.insert(Connections,script.Parent.Next.MouseButton1Click:connect(function() | |
script.Parent.Weapons.WeaponContainer.UIPageLayout:Next() | |
end)) | |
table.insert(Connections,script.Parent.Weapons.WeaponContainer.UIPageLayout.PageLeave:connect(function(page) | |
if getWeaponByName(page.Name) then | |
getWeaponByName(page.Name).UI:SetActive(false) | |
end | |
end)) | |
script.Parent.Weapons.WeaponContainer.UIPageLayout.PageEnter:connect(function(page) | |
if getWeaponByName(page.Name) then | |
getWeaponByName(page.Name).UI:SetActive(true) | |
end | |
end) | |
table.insert(Connections,script.Parent.Weapons.WeaponContainer.UIPageLayout.Stopped:connect(function(page) | |
script.Parent.Weapons.HelmetTitle.Text = page.Name:upper() | |
SoldierData.UnitWeaponType.Value = getWeaponByName(page.Name).Name | |
end)) | |
table.insert(Connections,script.Parent.Confirm.MouseButton1Click:connect(function() | |
SoldierData.SoldierModel.Value.EquipFromClient:FireServer(script.Parent.Weapons.WeaponContainer.UIPageLayout.CurrentPage.Name) | |
for _, weapon in pairs(Weapons) do | |
weapon.UI:SetActive(false) | |
weapon.UI:End() | |
end | |
for _, UI in pairs(script.Parent.Weapons.WeaponContainer:GetChildren()) do | |
if UI:IsA("Frame") then | |
UI:Destroy() | |
end | |
end | |
Weapons = {} | |
for _, c in pairs(Connections) do | |
c:Disconnect() | |
end | |
script.Parent.Parent.UIPageLayout:Next() | |
Connections = {} | |
end)) | |
end | |
end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Steps = script.Parent.Parent.Parent.Parent.Steps | |
local SoldierData = script.Parent.Parent.Parent.SoldierData | |
local Entry = Steps.Entry | |
local player = game.Players.LocalPlayer | |
player:WaitForChild("Allegiance",200) | |
local UnitOptions = require(game.ReplicatedStorage.UnitPrices) | |
local Connections = {} | |
table.sort(UnitOptions[player.Allegiance.Value],function(a,b) | |
return a.Cost < b.Cost | |
end) | |
Entry.Event:connect(function() | |
for _, v in pairs(script.Parent.ComparisonTable.Content:GetChildren()) do | |
if v:IsA("Frame") then | |
v:Destroy() | |
end | |
end | |
if UnitOptions then | |
local i = 0; | |
for unitTypeName, unitTypeData in pairs(UnitOptions[player.Allegiance.Value]) do | |
i = i + 1; | |
local UnitOption = game.ReplicatedStorage.SquadCustomizationUIs.UnitTemplate:Clone() | |
UnitOption.Name = unitTypeData.LiteralName | |
UnitOption.UnitType.Text = unitTypeData.Name | |
UnitOption.UnitCost.Text = tostring(unitTypeData.Cost) .. " CREDITS"; | |
UnitOption.CostValue.Value = unitTypeData.Cost | |
UnitOption.LayoutOrder = i; | |
table.insert(Connections,UnitOption.SelectButton.MouseButton1Click:connect(function() | |
if SoldierData.UnitType.Value ~= UnitOption.Name then | |
SoldierData.UnitType.Value = UnitOption.Name | |
SoldierData.SoldierModel.Value.Pants.PantsTemplate = unitTypeData.Clothes.Pants | |
SoldierData.SoldierModel.Value.Shirt.ShirtTemplate = unitTypeData.Clothes.Shirt | |
SoldierData.Cost.Value = UnitOption.CostValue.Value | |
end | |
end)) | |
UnitOption.Parent = script.Parent.ComparisonTable.Content | |
end | |
table.insert(Connections,script.Parent.Confirm.MouseButton1Click:connect(function() | |
for _, c in pairs(Connections) do | |
c:Disconnect() | |
end | |
script.Parent.Parent.UIPageLayout:Next() | |
end)) | |
end | |
end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Steps = script.Parent.Parent.Parent.Parent.Steps | |
local SoldierData = script.Parent.Parent.Parent.SoldierData | |
local Entry = Steps.UnitChosen | |
local Module3D = require(game.ReplicatedStorage.Module3D) | |
local ArmorService = require(game.ReplicatedStorage.ArmorModule) | |
local RemoteService = require(game.ReplicatedStorage.RemoteService) | |
local Helmets = {} | |
local player = game.Players.LocalPlayer | |
player:WaitForChild("Allegiance",200) | |
local Connections = {} | |
local function insertHelmet(name,helmet,UI3D) | |
table.insert(Helmets,{ | |
Name = name; | |
helmetModel = helmet; | |
UI = UI3D; | |
}) | |
end | |
local function getHelmetByName(name) | |
local result = nil | |
for _, helmet in pairs(Helmets) do | |
if name == helmet.Name then | |
result = helmet | |
break | |
end | |
end | |
return result | |
end | |
local UnitOptions = require(game.ReplicatedStorage.UnitPrices) | |
Entry.Event:connect(function(unitType) | |
if UnitOptions then | |
for i, unitTypeData in pairs(UnitOptions[player.Allegiance.Value][unitType].Helmets) do | |
local HelmetUI = game.ReplicatedStorage.SquadCustomizationUIs.Helmet:Clone() | |
HelmetUI.Name = unitTypeData.HelmetTitle.Value | |
insertHelmet(unitTypeData.HelmetTitle.Value,unitTypeData,Module3D:Attach3D(HelmetUI,unitTypeData:Clone())) | |
HelmetUI.Parent = script.Parent.Helmets.HelmetContainer | |
-- local UnitOption = game.ReplicatedStorage.SquadCustomizationUIs.UnitTemplate:Clone() | |
-- UnitOption.Name = unitTypeName | |
-- UnitOption.UnitType.Text = unitTypeData.Name | |
-- UnitOption.UnitCost.Text = tostring(unitTypeData.Cost) .. " CREDITS"; | |
-- UnitOption.CostValue.Value = unitTypeData.Cost | |
-- UnitOption.SelectButton.MouseButton1Click:connect(function() | |
-- if SoldierData.UnitType.Value ~= UnitOption.Name then | |
-- SoldierData.UnitType.Value = UnitOption.Name | |
-- SoldierData.SoldierModel.Value.Pants.PantsTemplate = unitTypeData.Clothes.Pants | |
-- SoldierData.SoldierModel.Value.Shirt.ShirtTemplate = unitTypeData.Clothes.Shirt | |
-- end | |
-- end) | |
-- UnitOption.Parent = script.Parent.ComparisonTable.Content | |
-- script.Parent.ComparisonTable.Content.UITableLayout:ApplyLayout() | |
end | |
for _, helmet in pairs(Helmets) do | |
helmet.UI:SetActive(true) | |
end | |
table.insert(Connections,script.Parent.Next.MouseButton1Click:connect(function() | |
script.Parent.Helmets.HelmetContainer.UIPageLayout:Next() | |
end)) | |
table.insert(Connections,script.Parent.Helmets.HelmetContainer.UIPageLayout.PageLeave:connect(function(page) | |
if getHelmetByName(page.Name) then | |
getHelmetByName(page.Name).UI:SetActive(false) | |
end | |
end)) | |
table.insert(Connections,script.Parent.Helmets.HelmetContainer.UIPageLayout.PageEnter:connect(function(page) | |
if getHelmetByName(page.Name) then | |
getHelmetByName(page.Name).UI:SetActive(true) | |
end | |
end)) | |
table.insert(Connections,script.Parent.Helmets.HelmetContainer.UIPageLayout.Stopped:connect(function(page) | |
script.Parent.Helmets.HelmetTitle.Text = page.Name:upper() .. (" Helmet"):upper() | |
end)) | |
table.insert(Connections,script.Parent.Confirm.MouseButton1Click:connect(function() | |
ArmorService:EquipArmorByName(script.Parent.Parent.Parent.SoldierData.SoldierModel.Value,getHelmetByName(script.Parent.Helmets.HelmetContainer.UIPageLayout.CurrentPage.Name).helmetModel.Name) | |
SoldierData.UnitHelmetType.Value = getHelmetByName(script.Parent.Helmets.HelmetContainer.UIPageLayout.CurrentPage.Name).helmetModel.Name | |
for _, c in pairs(Connections) do | |
c:Disconnect() | |
end | |
for _, helmet in pairs(Helmets) do | |
helmet.UI:End() | |
end | |
for _, UI in pairs(script.Parent.Helmets.HelmetContainer:GetChildren()) do | |
if UI:IsA("Frame") then | |
UI:Destroy() | |
end | |
end | |
Helmets = {} | |
script.Parent.Parent.UIPageLayout:Next() | |
Connections = {} | |
end)) | |
end | |
end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Steps = script.Parent.Parent.Parent.Parent.Steps | |
local SoldierData = script.Parent.Parent.Parent.SoldierData | |
local Entry = Steps.WeaponChosen | |
local Module3D = require(game.ReplicatedStorage.Module3D) | |
local RemoteService = require(game.ReplicatedStorage.RemoteService) | |
local Weapons = {} | |
local player = game.Players.LocalPlayer | |
player:WaitForChild("Allegiance",200) | |
local ConfirmConnection | |
local function insertWeapon(name,weapon,UI3D) | |
table.insert(Weapons,{ | |
Name = name; | |
weaponModel = weapon; | |
UI = UI3D; | |
}) | |
end | |
local function getWeaponByName(name) | |
local result = nil | |
for _, weapon in pairs(Weapons) do | |
if name == weapon.Name then | |
result = weapon | |
break | |
end | |
end | |
return result | |
end | |
Entry.Event:connect(function(unitType) | |
ConfirmConnection = script.Parent.Confirm.MouseButton1Click:connect(function() | |
local balance, transactionResult = RemoteService.fetch("Server","MakeTransaction","Withdraw",SoldierData.Cost.Value) | |
if transactionResult then | |
ConfirmConnection:disconnect() | |
local SoldierObj = { | |
UnitNumber = script.Parent.Parent.Parent.Parent.SquadData.MembersHired.Value + 1; | |
Type = SoldierData.UnitType.Value; | |
Helmet = SoldierData.UnitHelmetType.Value; | |
Weapon = SoldierData.UnitWeaponType.Value; | |
} | |
local soldier = RemoteService.fetch("Server","CreateSoldier",SoldierObj) | |
if soldier then | |
script.Parent.Parent.Parent.Parent.SquadData.MembersHired.Value = script.Parent.Parent.Parent.Parent.SquadData.MembersHired.Value + 1 | |
end | |
game.ReplicatedStorage.DestroySoldierModel:FireServer(_G.ActiveTrooper) | |
if script.Parent.Parent.Parent.Parent.SquadData.MembersHired.Value >= 4 then | |
else | |
script.Parent.Parent.Parent.Parent.CreateNewUnit:Fire() | |
script.Parent.Parent.UIPageLayout:Next() | |
end | |
else | |
script.Parent.Parent.Parent.Parent.PurchasePrompt.Visible = true | |
end | |
end) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment