I am not very good at this field. I think the title itself is self explanatory. I have a mesh part that would like to be on the back of my player. PS : It is R6. Thank you!
1 Like
before the writing code you need to set these things if you have a realistic backpack
if the blue dot (that appears when you click the model) looks like the picture above. You need to set pivot position like the picture below.
To do this:
1- Click the backpack
2- Go to the properties
3- Find the property “PivotOffset”
4-
5- Change the position(Z offset of the position) until blue dot comes to the middle of the backpack like the last backpack photo i added.
insert a new script to the ServerScriptService and write this:
function weldParts(object,target)
local weld = Instance.new("Weld")
weld.Parent = object
weld.Part0 = object
weld.Part1 = target
return weld
end
function checkpos(pos)
if pos.Z < 0 then
return Vector3.new(pos.X,pos.Y,pos.Z*-1)
else
return pos
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local backpack = YOURBACKPACK:Clone()
local torso = character:WaitForChild("Torso")
backpack.Anchored = false
local weld = weldParts(torso,backpack)
backpack.Parent = workspace --// you can set it to character
local pos = checkpos(backpack.PivotOffset.Position)
weld.C1 = CFrame.new(pos) * CFrame.Angles(0,math.rad(180),0)
end)
end)
2 Likes
Thank you so much, FYI for users looking at this post. It must only be a mesh and nothing else.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.