Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why does why my weld break while the player is moving?

i'm using a weld where it welds to the HumanoidRootPart only if input is detected and the problem here is that while your moving and spamming equip and unequip button, the object starts to teleport around and the weld just breaks even when you stand still it is still broken.

Equipping

--|Services|--
local replicatedStorage = game:GetService('ReplicatedStorage')

--|RemoteFunction|--
local remoteFunction = replicatedStorage.RemoteFunction

--|Weld|--
local weld = Instance.new('Weld')

--|Book|--
local openBook = replicatedStorage.CloverBookEarth

--|Book Clone|--
local bookClone = openBook:Clone()

--|Function|--
function remoteFunction:OnServerInvoke(player)
	local character = player.Character
	
	bookClone.Parent = workspace
	
	bookClone.Name = player.Name .."'s Book"
	
	bookClone.Spine.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(-2,1,-3) * CFrame.Angles(math.rad(0),math.rad(90),math.rad(-90)) * CFrame.Angles(math.rad(-15),0,0)
	
	weld.Parent = bookClone.PrimaryPart
	
	weld.C0 = character.HumanoidRootPart.CFrame:inverse()
	weld.C1 = bookClone.Spine.CFrame:inverse()
	
	weld.Part0 = character.HumanoidRootPart
	weld.Part1 = bookClone.Spine
end

UnEqupping

--|Services|--
local replicatedStorage = game:GetService('ReplicatedStorage')

--|RemoteFunction|--
local remoteFunction = replicatedStorage.RemoteFunction2

--|Function|--
function remoteFunction:OnServerInvoke(player)
	local openBook = game.Workspace.CloverBookEarth
	
	openBook.Parent = replicatedStorage
end

1 answer

✓ Accepted answer

Put bookClone in function.

function remoteFunction:OnServerInvoke(player)
    local bookClone = openBook:Clone()
end

This discussion is preserved as it was. New answers, comments, and votes are closed.