So, I have a script that automatically applies models to your character based off of your rank in my group. The only problem is that when you reset, the armor does not apply back to your character. The model only applies to your character when you join, but not when you reset. I would like it to still apply to your character when you reset. Is there anyway to fix this?
Recording:
Code:
You need to do a Player.CharacterAdded event inside the Players.PlayerAdded event to reload the character.
(post withdrawn by author, will be automatically deleted in 1 hour unless flagged)
Where would I put this in the script?
You forgot to add :Clone() for the HazmatHelmet and the HazmatBackpack. ( I think. If not, then you can remove the :Clone() )
I also added the CharacterAdded function, and updated the script.
Here is the script:
local Players = game:GetService("Players")
local GroupId = 9719071
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAppearanceLoaded:Connect(function(Character)
if Player:IsInGroup(GroupId) then
if Player:GetRankInGroup(GroupId) == 255 then
local Humanoid = Character:WaitForChild("Humanoid")
local Vest = game.ServerStorage.ArmorItems.Vest:Clone()
local Helmet = game.ServerStorage.ArmorItems.Helmet:Clone()
Character:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=5307571814"
Character:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=6640758096"
Humanoid:RemoveAccessories()
Vest.Parent = Character
Helmet.Parent = Character
elseif Player:GetRankInGroup(GroupId) == 254 then
local Humanoid = Character:WaitForChild("Humanoid")
local HazmatHelmet = game.ServerStorage.ArmorItems.HazmatHelmet:Clone()
local HazmatBackpack = game.ServerStorage.ArmorItems.HazmatBackpack:Clone()
Character:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=6412906235"
Character:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=6412724760"
Humanoid:RemoveAccessories()
HazmatHelmet.Parent = Character
HazmatBackpack.Parent = Character
end
end
end)
end)
This works but the :RemoveAccessories does not work anymore for some reason.
Is the HazmatHelmet and the HazmatBackpack supposed to be cloned?
Indeed it is supposed to be. But still the remove accessories function does not work.
I updated the script. I made it wait for the character to load.
Now the code does not work at all, now the uniform does not apply when you reset again.
I think the problem, is that the accessories aren’t loaded when the :RemoveAccessories() is called.
I just edited the script, and tried the CharacterAppearanceLoaded function. Try it now.
That works perfectly, thank you so much!
1 Like
It appears it only runs when the Player is added. Try adding an extra function in the added event, to make sure it occurs every life.
Player.CharacterAdded:Connect()
1 Like