How Do I Make a Armor Script without a Localscript? plz don't close this question
local p = game.Players.LocalPlayer d = false script.Parent.Selected:connect(function(mouse) mouse.Button1Down:connect(function() if d then return end d = true local c = p.Character p.Armor.Defend.Value = p.Armor.Defend.Value+3 p.Armor.HitPoint.Value = p.Armor.HitPoint.Value+15 local g = c:GetChildren() for i = 1,#g do if g[i]:IsA("CharacterMesh") or g[i]:IsA("Hat") or g[i]:IsA("Pants") or g[i]:IsA("Shirt") then g[i]:Remove() elseif g[i]:IsA("BasePart") and g[i].Name ~= "Torso" then end end script.Parent:findFirstChild("HeavyIronArmor Left Arm"):Clone().Parent = c script.Parent:findFirstChild("HeavyIronArmor Left Leg"):Clone().Parent = c script.Parent:findFirstChild("HeavyIronArmor Right Arm"):Clone().Parent = c script.Parent:findFirstChild("HeavyIronArmor Right Leg"):Clone().Parent = c script.Parent:findFirstChild("HeavyIronArmor Torso"):Clone().Parent = c local h = Instance.new("Hat") h.Name = "Helmet" local hp = Instance.new("Part") hp.Name = "Handle" hp.Parent = h hp.Locked = true hp.FormFactor = "Symmetric" hp.Size = Vector3.new(1,1,1) hp.TopSurface = "Smooth" hp.BottomSurface = "Smooth" hp.Position = c.Head.Position h.AttachmentPos = Vector3.new(0,0.3,-0.03) h.Parent = c end) end) script.Parent.Deselected:connect(function() script.Parent:Remove() end)
ISSUES
connect
is deprecated in favor of Connect
:Remove()
is deprecated in favor of :Destroy()
":findFirstChild()"should have a capitalized F -- :FindFirstChild()
HopperBin
is deprecated in favor of Tool
Hat
is deprecated in favor of Accessory
FormFactor and SurfaceType are Enums, not strings
GENERAL PRACTICE
You can use the for-loop in pairs to iterate through a table without the [#]
Use WaitForChild rather than FindFirstChild to get a variable you will be using later in the script (since you cannot change a nil value)
REVISED
Server Script
local r = Instance.new("RemoteEvent") r.Name = "ArmorChange" r.Parent = game:GetService("ReplicatedStorage") local d = true r.OnServerEvent:Connect(function(p) if d == false then return end d = false local defend = p:WaitForChild("Armor"):WaitForChild("Defend") local hitpoint = p:WaitForChild("Armor"):WaitForChild("HitPoint") defend.Value = defend.Value + 3 hitpoint.Value = hitpoint.Value + 15 local c = p.Character for i, g in pairs(c:GetChildren()) do if g:IsA("CharacterMesh") or g:IsA("Accessory") or g:IsA("Pants") or g:IsA("Shirt") then g:Destroy() end end game:GetService("ServerStorage"):WaitForChild("HeavyIronArmor Left Arm"):Clone().Parent = c game:GetService("ServerStorage"):WaitForChild("HeavyIronArmor Left Leg"):Clone().Parent = c game:GetService("ServerStorage"):WaitForChild("HeavyIronArmor Right Arm"):Clone().Parent = c game:GetService("ServerStorage"):WaitForChild("HeavyIronArmor Right Leg"):Clone().Parent = c game:GetService("ServerStorage"):WaitForChild("HeavyIronArmor Torso"):Clone().Parent = c local h = Instance.new("Accessory") h.Name = "Helmet" local hp = Instance.new("Part") hp.Name = "Handle" hp.Parent = h hp.Locked = true hp.FormFactor = Enum.FormFactor.Symmetric hp.Size = Vector3.new(1, 1, 1) hp.TopSurface = Enum.SurfaceType.Smooth hp.BottomSurface = Enum.SurfaceType.Smooth hp.Position = c:WaitForChild("Head").Position h.AttachmentPos = Vector3.new(0, 0.3, -0.03) h.Parent = c end)
Local Script
local tool = script.Parent local r = game:GetService("ReplicatedStorage"):WaitForChild("ArmorChange") tool.Equipped:Connect(function(mouse) r:FireServer() end) tool.Unequipped:Connect(function() tool:Destroy() end)
Move your "Armor" parts to the ServerStorage, change the "HopperBin" to a "Tool"
The scripts above create a RemoteEvent for you, make sure the local script is under the tool, the server script can be under ServerScriptService.