In this script, how could I make the uniform changing process automatic?
Hello, I've recently got into scripting, and have started dissecting free model scripts to try and learn as much as I can.
I would like to know what part of this script is responsible for the player having to press a button to equip the uniform, and what parts I'd need to remove to make the player equip the uniform on spawn.
The group, pants and shirt IDs are all stored as IntValues, and the script works thus far:
01 | print ( "Loaded Uniform Script." ) |
03 | repeat wait() until game.Players.LocalPlayer |
04 | local Player = game.Players.LocalPlayer |
05 | local Character = Player.Character |
08 | local ScreenGui = script.Parent |
09 | local UniformButton = ScreenGui:WaitForChild( "UniformButton" ) |
11 | local Settings = script.Parent:WaitForChild( "Settings" ) |
12 | local CertainTeam = Settings:WaitForChild( "CertainTeam" ) |
13 | local CertainTeamColour = CertainTeam:WaitForChild( "TeamColor" ) |
15 | local UniformRanks = Settings:WaitForChild( "UniformRanks" ) |
16 | local GroupId = Settings:WaitForChild( "GroupId" ) |
22 | if CertainTeam.Value then |
23 | if Player.TeamColor ~ = CertainTeamColour.Value then |
28 | for i, v in pairs (UniformRanks:GetChildren()) do |
29 | if v:IsA( "NumberValue" ) or v:IsA( "IntValue" ) then |
30 | if string.find(v.Name, "Rank" ) then |
31 | table.insert(Ranks, string.sub(v.Name, 1 , 5 )) |
40 | UniformButton.MouseButton 1 Down:connect( function () |
41 | if Player:IsInGroup(GroupId.Value) then |
42 | if table.getn(Ranks) ~ = 0 then |
43 | for i, v in pairs (Ranks) do |
44 | local PlayerRank = Player:GetRankInGroup(GroupId.Value) |
45 | local Rank = UniformRanks:FindFirstChild(v) |
47 | if PlayerRank > = Rank.Value then |
48 | if PlayerRank > HighestRank then |
50 | HighestRank = Rank.Value |
55 | if HighestRank ~ = 0 then |
57 | for i, v in pairs (UniformRanks:GetChildren()) do |
58 | if v.Value = = HighestRank then |
65 | for i, Object in next , Character:GetChildren() do |
66 | if Object:IsA( "Shirt" ) or Object:IsA( "Pants" ) then |
71 | local Shirt = Instance.new( "Shirt" , Character) |
72 | local Pants = Instance.new( "Pants" , Character) |
73 | Shirt.ShirtTemplate = Uniform.Shirt |
74 | Pants.PantsTemplate = Uniform.Pants |