Firstly you are putting an instance in a Vector, instead it should be 3 values. As well as the UpperTorso has a property called .Position
which you can use to move it towards the player.
Secondly, inside of the PlayerAdded function you should have a CharacterAdded function, it will look as follows:
game:GetService("Players").PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
-- Code
end)
end)
You get the character instance in parameter with this function.
Furthermore, you are able to retreive a player’s character by using the .Character
property of the player instance like so player.Character
, else use the parameter of the .CharacterAdded
function.
In addition, please use .CFrame
instead of .Position
, a CFrame is the orientation and the position of an instance (this is a basic explanation of it, there is more to it though).
As well was that you are just moving 1 part inside of the model, clonedVest
, called Middle
instead you can move the whole model by using Model:SetPrimaryPartCFrame(cframe)
, note you need to have the primary part set to be the middle (I will set the primary part in the script to middle as well just to be sure, please delete the line of code if you already did this).
Lastly, this should be run somewhere inside the PlayerAdded statement.
Note that you also forgot to change the Parent of the cloned vest to worspace
or character
.
Taking all of this to account your script would look something like this:
local TCDVest = game.ServerStorage.TCDVest
game.Players.PlayerAdded:Connect(function(player) -- player is a parameter of this function
-- Have an if statement inside of the PlayerAdded function instead of the CharacterAdded function so you waste less space.
if player.Name == "pinchpotmonster" then
player.CharacterAdded:Connect(function(character) -- character is a parameter of this function
local clonedVest = TCDVest:Clone() -- clone the vest whenever the player respawns
clonedVest:SetPrimaryPartCFrame(character.LowerTorso.CFrame) -- position and rotate the vest
clonedVest.Parent = character -- parent the vest to make it visible
-- Now last of all you have to weld it to the player!
end)
end
end)
Now the only things left which you should do is weld the primary part of the cloned vest to the lower torso of the player’s character and have the vest parented inside ServerStorage welded together already.