My problem is I’m trying to get a wearable vest which I already succeeded with a help of an old script I had. But then I replaced the mesh with a newer updated mesh for the vest and the only problem I have is I don’t know how to rotate the vest.
Problem:
What I tried to do was add this “p.CFrame = p.CFrame * CFrame.Angles(0, math.rad(5), 0)” but it had no effect
Script
local vest = script.Parent.Handle
script.Parent.RemoteEvent.OnServerEvent:connect(function(plr, …)
local t = {…}
if t[1] == “PutOn” then
h = Instance.new(“Hat”)
p = Instance.new(“Part”)
h.Name = “Hat” – It doesn’t make a difference, but if you want to make your place in Explorer neater, change this to the name of your hat.
p.Parent = h
p.Position = plr.Character.Torso.Position
p.Name = “Handle”
p.formFactor = 0
p.Size = Vector3.new(-0,-0,-1)
p.BottomSurface = 0
p.TopSurface = 0
p.BrickColor = BrickColor.new(“Really black”)
p.Locked = true
vest.Mesh:Clone().Parent = p
h.Parent = plr.Character
h.AttachmentPos = Vector3.new(0, 2, 0.05) – Change these to change the positiones of your hat, as I said earlier.
vest.Transparency = 1
plr.Character.Humanoid.MaxHealth = 150
end
if t[1] == “TakeOff” then
h:remove()
plr.Character.Humanoid.MaxHealth = 100
vest.Transparency = 0
end
Why use hats and stuff when you can just simply change the Vest’s CFrame and then Weld it to the player? I just don’t like idea of your way since welds and CFrame would be way simpler.
You will have to adjust the “CFrame.new” line and “CFrame.Angles”. What that will do is set the CFrame (Rotation and position) of vest to the torso. The other two parts adjust the position and rotation. math.rad is needed to convert degrees to radians since CFrame.Angles uses radians.
Once you successfully set the position of the Vest you have to weld it. In order to do that you first create a weld by typing out this line of code
local weld = Instance.new(“WeldConstraint”)
Then you set the Part0 (main part) and Part1 (Part that has to be attached, for you its the vest)
weld.Part0 = Torso
weld.Part1 = vest
Lastly you set the parent of the weld to either the torso or the part.
weld.Parent = Torso
Make sure that the vest is not anchored. Also not really required but I tend to like to make the accessories not collidable and massless.
Also since you are new to this I suggest taking a look at CFrames and welds. Here are some useful links:
I really appreciate your help and you taking the time to try to explain this. But I have no clue what I’m doing. I’m just tryna rotate the vest lol. But thank you ALOT!