Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why won't my automatic group rank hat script work?

Asked by 5 years ago
Edited by User#24403 5 years ago

```lua local ActualRank = require(game.ServerStorage.Modules.ActualRank)

GROUPID = "4849587" --sweden

GROUP2ID = "4860070" --artillery

GROUP3ID = "4860080" --dragoon

Group4ID = "4860021" -- grenadiers

Group5ID = "4860066" -- Infrantry

function weldParts(part0, part1)

local newWeld = Instance.new("Weld")

newWeld.Part0 = part0

newWeld.Part1 = part1

newWeld.C0 = CFrame.new()

newWeld.C1 = part1.CFrame:toObjectSpace(part0.CFrame)

newWeld.Parent = part0

end

function AddHat(hat,character)

local head = character:FindFirstChild("Head")

local newHat = hat:Clone()

newHat:SetPrimaryPartCFrame(head.CFrame)

newHat.PrimaryPart:Destroy()

for _, part in pairs (newHat:GetChildren()) do

if part:IsA("BasePart") then

weldParts(head, part)

part.CanCollide = false

part.Anchored = false

end

end

newHat.Parent = character

newHat:SetPrimaryPartCFrame(head.CFrame)

end

function ChooseHat(character)

wait(1)

local player = game.Players:GetPlayerFromCharacter(character)

local hat = nil

local Success,Rank = ActualRank.Get(player,GROUP2ID)

if not Success then Rank = player:GetRankInGroup(GROUP2ID) end

if (Rank == 255 or Rank == 8) then

hat = nil

elseif (Rank >= 5) then

hat = game.ServerStorage.Uniform.Hats.DragoonOfficer

elseif (Rank >= 1) then

hat = game.ServerStorage.Uniform.Hats.DragoonRanker

end

if (hat == nil) then

Success,Rank = ActualRank.Get(player,GROUPID) -- Check sweden

if not Success then Rank = player:GetRankInGroup(GROUPID) end

if (Rank == 0) then

hat = nil

elseif (Rank > 254) then

hat = game.ServerStorage.Uniform.Hats.KingOfSweden

elseif (Rank == 254) then

hat = game.ServerStorage.Uniform.Hats.ChiefOfArmy

elseif (Rank >= 7) then

hat = game.ServerStorage.Uniform.Hats.Officer

elseif (Rank >= 1) then

hat = game.ServerStorage.Uniform.Hats.Ranker

end

end

if (hat == nil) then

Success,Rank = ActualRank.Get(player,GROUPID) -- Check sweden

if not Success then Rank = player:GetRankInGroup(GROUPID) end

if (Rank == 1) then

hat = nil

elseif (Rank >= 254) then

hat = game.ServerStorage.Uniform.Hats.KingOfSweden

elseif (Rank == 254) then

hat = game.ServerStorage.Uniform.Hats.General

elseif (Rank >= 7) then

hat = game.ServerStorage.Uniform.Hats.Officer

elseif (Rank >= 1) then

hat = game.ServerStorage.Uniform.Hats.Ranker

end

end

-- if (hat == nil) then

-- Success,Rank = ActualRank.Get(player,GroupVariable)

-- if not Success then Rank = player:GetRankInGroup(GroupVariable) end

-- if (Rank == value) then

-- hat == hat.value

-- elseif (Rank >= value) the

-- hat == hat.value

-- end

-- end

if hat then

AddHat(hat,character)

end

end

game.Players.ChildAdded:Connect(function(player)

player.CharacterAdded:Connect(ChooseHat)

end) ```

0
You should use HumanoidDescription. It's easier. JakyeRU 637 — 5y

Answer this question