Hey guys I’m trying to make this book appear on the back of my character vertically. I have found this code:
local Players = game:GetService("Players")
local function OnPlayerAdded(Client)
local Part = workspace.BeginnerBook
local Weld = Instance.new("WeldConstraint")
if Client.Character then
wait(0.5)
Part.Position = Client.Character.UpperTorso.Position
Part.Orientation = Client.Character.UpperTorso.Orientation
Weld.Parent = Client.Character
Part.Parent = game.Workspace
Weld.Part0 = Client.Character.UpperTorso
Weld.Part1 = Part
Weld.C0 = Part.CFrame.new(0,0,0) *CFrame.new(0,0,0)
else
Client.CharacterAdded:Connect(function()
wait(0.5)
Part.Position = Client.Character.UpperTorso.Position
Part.Orientation = Client.Character.UpperTorso.Orientation
Weld.Parent = Client.Character
Part.Parent = game.Workspace
Weld.Part0 = Client.Character.UpperTorso
Weld.Part1 = Part
end)
end
end
Players.PlayerAdded:Connect(OnPlayerAdded)
Although it just ends making this, i’ve tried messing with it but nothing changes when i mess with the CFrame.
2 Likes
Repositioning Welded Parts
Roblox handles moving a welded part differently depending on whether the part was moved using its Position
or with its CFrame
.
If a welded part’s Position
is updated, the part will move but none of the connected parts will move with it. The weld will recalculate the offset from the other part based on the part’s new position.
-- Create two parts and position them at the same height
local partA = Instance.new("Part")
local partB = Instance.new("Part")
partA.Position = Vector3.new(0, 10, 0)
partB.Position = Vector3.new(0, 10, 10)
partA.Parent = workspace
partB.Parent = workspace
-- Weld the two parts together
local weld = Instance.new("WeldConstraint")
weld.Parent = workspace
weld.Part0 = partA
weld.Part1 = partB
-- Update the position of the first part; the first part will move but the second will stay where it started
partA.Position = Vector3.new(0, 20, 0)
In contrast, if a part’s CFrame
is updated, that part will move and any part welded to that part will also move. These other parts will be moved to make sure they maintain the same offset as when the weld was created.
-- Create two parts and position them at the same height
local partA = Instance.new("Part")
local partB = Instance.new("Part")
partA.Position = Vector3.new(0, 10, 0)
partB.Position = Vector3.new(0, 10, 10)
partA.Parent = workspace
partB.Parent = workspace
-- Weld the two parts together
local weld = Instance.new("WeldConstraint")
weld.Parent = workspace
weld.Part0 = partA
weld.Part1 = partB
-- Update the CFrame of the first part; the second part will also move to maintain the offset of the weld
partA.CFrame = CFrame.new(0, 20, 0)
WeldConstraint | Documentation - Roblox Creator Hub
I think your problem may be the because you are using CFrame
, which as stated above (which is taken from the developer hub) moves everything which is attached to it. Try using Position
instead and tell us the new results.
4 Likes
I don’t think you need such a huge script for that. First off you need to add an attachment to the main part of your book. If your book consists of more than 1 part weld everything together and name the main part ‘Handle’. After that put your book inside a accessory and name the attachment ‘BodyBackAttachment’. This makes sure that your book is at the back of your character. After finishing put the Book Accesory inside ServerStorage. It should then look like this:
Then make a script which clones this accessory every time a player’s character is added and parents the cloned book to this character.
1 Like