Where in the model is the script? I was assuming it was inside a clickable version of the helmet, or is it running from a GUI?
the script is in the âheadâ
its the hat script
Can you adjust the code I gave you so that the line
local model = script.Parent
refers to the helmet model and see if it still throws the same error? I think it might need to be
local model = script.Parent.Parent.Face1
instead.
It appears to work but the helmet is now flopping around and falling apart. Every time I Anchor it I get stuck in the model
Does it pull you into the equipment rack when you put the helmet on?
Yes and if Un-Anchored it does this and moves
when put on it stays off the head
local model = script.Parent
local helmets = serverStorage.Helmets
local shields = serverStorage.Shields
function boop(Player)
if Player.Character:findFirstChild("Humanoid") ~= nil and Player.Character:findFirstChild("Face1") == nil then
local new_helmet = model:Clone()
local rank = Player:GetRankInGroup(4875042)
local rank_helmet_base = helmets:FindFirstChild(rank)
local rank_shield_base = shields:FindFirstChild(rank)
if rank_helmet_base then
local rank_helmet = rank_helmet_base:Clone()
rank_helmet.CFrame = new_helmet.Helmet1.CFrame
rank_helmet.Parent = new_helmet
new_helmet.Helmet1:Remove()
else
warn("No helmet found for group rank "..rank..".")
end
if rank_shield_base then
local rank_shield = rank_shield_base:Clone()
rank_shield.CFrame = new_helmet.Shield.CFrame
rank_shield.Parent = new_helmet
new_helmet.Shield:Remove()
else
warn("No shield found for group rank "..rank..".")
end
new_helmet.Parent = Player.Character
new_helmet.PrimaryPart = new_helmet.Middle
new_helmet:SetPrimaryPartCFrame(Player.Character.Head.CFrame)
local w= Instance.new("WeldConstraint")
w.Part0 = new_helmet.Middle
w.Part1 = Player.Character.Head
w.Parent = new_helmet.Middle
for _,v in pairs(new_helmet:GetChildren()) do
if v:isA("Part") or v:isA("MeshPart") or v:isA("UnionOperation")then
local w = Instance.new("WeldConstraint")
w.Part0 = new_helmet.Middle
w.Part1 = v
w.Parent = new_helmet.Middle
v.Anchored = false
v.CanCollide = false
end
end
end
end
script.Parent.ClickDetector.MouseClick:connect(boop)
I redid the code responsible for the welds. It was an old style that can cause those issues, and the new constraint system is easier to use anyway. I donât know if it will fix the problems, but it might. Is the code throwing any errors?
e: Also, what does that âWeld for Morphsâ script inside the Face1 model do?
and idk it was in the model when I purchased it
e: weld morphs keeps all the addons together like the radio and stuff. I removed it and everything fell apart
I gave you the wrong opening section in the code I just pasted in - that line beginning with local model =
needs to be changed to reference the Face1 model. I changed it here but forgot to in my editor.
local serverStorage = game:GetService("ServerStorage")
local model = script.Parent.Parent.Face1
local helmets = serverStorage.Helmets
local shields = serverStorage.Shields
function boop(Player)
if Player.Character:findFirstChild("Humanoid") ~= nil and Player.Character:findFirstChild("Face1") == nil then
local new_helmet = model:Clone()
local rank = Player:GetRankInGroup(4875042)
local rank_helmet_base = helmets:FindFirstChild(rank)
local rank_shield_base = shields:FindFirstChild(rank)
if rank_helmet_base then
local rank_helmet = rank_helmet_base:Clone()
rank_helmet.CFrame = new_helmet.Helmet1.CFrame
rank_helmet.Parent = new_helmet
new_helmet.Helmet1:Remove()
else
warn("No helmet found for group rank "..rank..".")
end
if rank_shield_base then
local rank_shield = rank_shield_base:Clone()
rank_shield.CFrame = new_helmet.Shield.CFrame
rank_shield.Parent = new_helmet
new_helmet.Shield:Remove()
else
warn("No shield found for group rank "..rank..".")
end
new_helmet.Parent = Player.Character
new_helmet.PrimaryPart = new_helmet.Middle
new_helmet:SetPrimaryPartCFrame(Player.Character.Head.CFrame)
local w= Instance.new("WeldConstraint")
w.Part0 = new_helmet.Middle
w.Part1 = Player.Character.Head
w.Parent = new_helmet.Middle
for _,v in pairs(new_helmet:GetChildren()) do
if v:isA("Part") or v:isA("MeshPart") or v:isA("UnionOperation")then
local w = Instance.new("WeldConstraint")
w.Part0 = new_helmet.Middle
w.Part1 = v
w.Parent = new_helmet.Middle
v.Anchored = false
v.CanCollide = false
end
end
end
end
script.Parent.ClickDetector.MouseClick:connect(boop)
Formatting missed the first line of code in this reply, itâs been edited.
Same Issue. The model doesnât come onto my head or pull me into the locker
This is the console now
and from the looks of it no longer changes the helmet color unless thatâs an issue with the anchoring
Update: So I redid the Humanoid and it now places it on my head but the one on the locker still flops
You might want to check if the Face1 model is anchored properly, but I can just make the script anchor it again at runtime to see. Just add this between lines 5 and 7.
for _,v in pairs(model:GetChildren()) do
if v:isA("Part") or v:isA("MeshPart") or v:isA("UnionOperation") then
v.Anchored = true
end
end
All Working, No Errors. Thanks! The Only issue I have now is the Remove Gear Button removes the gear but not the GUI.
No problem! You might want to look into how the GUI gets placed in the playerâs GUI folder, you might need to add some lines digging in there and getting it out. Deleting something on a button click shouldnât be too bad.
Hey Deggy quick issue i noticed. Im having an issue with the Helmet On/Off function with the system you made. The Original Helmet in the Helmet that has no texture doesnât come off the head. How could I call the helmet to the script without putting all the different helmets into the script
I donât think anyone has given a correct solution, You cant change textures in a surface appearance with scripts, the texture never updates. To do what your trying to do I suggest storing the textures in replicated storage and moving them into the helmet based on the chosen rank, if this doesnât work try putting the helmets themselves in replicated storage.
The stuff above works. The only issue Iâm running into is the helmet model now being able to be taken off with the GUI I need to find a way to call the helmet to the button