Hello developers!
I have made a tool that gives you a knight helmet and changes your outfit to middle age style’d outfit but the Shirts/Pants changing script won’t work and there are no errors, I tried using assets/contentprovidor.etc but nothing worked, here is the script:
local AttireTool = script.Parent
local Wearing = false
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Pants = Character:WaitForChild("Pants")
local Shirt = Character:WaitForChild("Shirt")
local CurrentPants = Pants.PantsTemplate
local CurrentShirt = Shirt.ShirtTemplate
local AttireRequest = "DefaultAttire"
local Hum = Character:WaitForChild("Humanoid")
local EquipTrack = Hum:LoadAnimation(script:WaitForChild("Equip"))
local UnEquipTrack = Hum:LoadAnimation(script:WaitForChild("Unequip"))
local Event = game.ReplicatedStorage.Events.Attire
AttireTool.Activated:Connect(function()
if Wearing then
UnEquipTrack:Play()
Event:FireServer(Player, Shirt, Pants, CurrentShirt, CurrentPants, AttireRequest, Wearing, Character)
Wearing = not Wearing
elseif not Wearing then
EquipTrack:Play()
Event:FireServer(Player, Shirt, Pants, CurrentShirt, CurrentPants, AttireRequest, Wearing, Character)
Wearing = not Wearing
end
end)
Server script:
local ContentProvidor
local Event = game.ReplicatedStorage.Events.Attire
local DefaultAttire = game.ReplicatedStorage.Attires.Knight
local DefaultAttireShirt = "http://www.roblox.com/asset/?id=1488118250"
local DefaultAttirePants = "http://www.roblox.com/asset/?id=1487600311"
Event.OnServerEvent:Connect(function(plr, Player, Shirt, Pants, CurrentShirt, CurrentPants, AttireRequest, Wearing, Character)
if AttireRequest == "DefaultAttire" and not Wearing then
for _,Part in pairs(Character:GetChildren()) do
if Part:IsA("Accessory") then
local handle = Part.Handle
handle.Transparency = 1
end
end
Shirt.ShirtTemplate = DefaultAttireShirt
Pants.PantsTemplate = DefaultAttirePants
local Head = Character.Head
local CurrentAttire = DefaultAttire:Clone()
local NewWeld = Instance.new("Weld")
NewWeld.Part0 = CurrentAttire
NewWeld.Part1 = Head
NewWeld.Parent = CurrentAttire
NewWeld.C0 = CFrame.new(0,-0.2,0)
CurrentAttire.Parent = Head
elseif AttireRequest == "DefaultAttire" and Wearing then
for _,Part in pairs(Character:GetChildren()) do
if Part:IsA("Accessory") then
local handle = Part.Handle
handle.Transparency = 0
end
end
Character.Head:FindFirstChild("Knight"):Destroy()
Shirt.ShirtTemplate = CurrentShirt
Pants.PantsTemplate = CurrentPants
end
end)
here is your client code mistake you added player as an argument which you shouldnt do so it is automatically provided by roblox so try this code
local AttireTool = script.Parent
local Wearing = false
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Pants = Character:WaitForChild("Pants")
local Shirt = Character:WaitForChild("Shirt")
local CurrentPants = Pants.PantsTemplate
local CurrentShirt = Shirt.ShirtTemplate
local AttireRequest = "DefaultAttire"
local Hum = Character:WaitForChild("Humanoid")
local EquipTrack = Hum:LoadAnimation(script:WaitForChild("Equip"))
local UnEquipTrack = Hum:LoadAnimation(script:WaitForChild("Unequip"))
local Event = game.ReplicatedStorage.Events.Attire
AttireTool.Activated:Connect(function()
if Wearing then
UnEquipTrack:Play()
Event:FireServer(Shirt, Pants, CurrentShirt, CurrentPants, AttireRequest, Wearing, Character)
Wearing = not Wearing
elseif not Wearing then
EquipTrack:Play()
Event:FireServer(Shirt, Pants, CurrentShirt, CurrentPants, AttireRequest, Wearing, Character)
Wearing = not Wearing
end
end)
and also you added player as in 2 parameters here is a fix
local ContentProvidor
local Event = game.ReplicatedStorage.Events.Attire
local DefaultAttire = game.ReplicatedStorage.Attires.Knight
local DefaultAttireShirt = "http://www.roblox.com/asset/?id=1488118250"
local DefaultAttirePants = "http://www.roblox.com/asset/?id=1487600311"
Event.OnServerEvent:Connect(function(Player, Shirt, Pants, CurrentShirt, CurrentPants, AttireRequest, Wearing, Character)
if AttireRequest == "DefaultAttire" and not Wearing then
for _,Part in pairs(Character:GetChildren()) do
if Part:IsA("Accessory") then
local handle = Part.Handle
handle.Transparency = 1
end
end
Shirt.ShirtTemplate = DefaultAttireShirt
Pants.PantsTemplate = DefaultAttirePants
local Head = Character.Head
local CurrentAttire = DefaultAttire:Clone()
local NewWeld = Instance.new("Weld")
NewWeld.Part0 = CurrentAttire
NewWeld.Part1 = Head
NewWeld.Parent = CurrentAttire
NewWeld.C0 = CFrame.new(0,-0.2,0)
CurrentAttire.Parent = Head
elseif AttireRequest == "DefaultAttire" and Wearing then
for _,Part in pairs(Character:GetChildren()) do
if Part:IsA("Accessory") then
local handle = Part.Handle
handle.Transparency = 0
end
end
Character.Head:FindFirstChild("Knight"):Destroy()
Shirt.ShirtTemplate = CurrentShirt
Pants.PantsTemplate = CurrentPants
end
end)
As @FlashFlame_Roblox said, ShirtId and ShirtTemplateId are two different things. You need to set it to the ShirtTemplateId and NOT the ShirtId. To get the ShirtTemplateId, just add a shirt to a dummy and paste the ShirtId in the box. Then as soon as you click enter, you will see a new set of numbers. That is the ShirtTemplateId.
You have to do it manually on a dummy in the Studio. When you pasted the Id in the script in, it will turn into a different one. And take that one and slap it on your script.