Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
0
Answered by
OnaKat 444 Moderation Voter
5 years ago
Edited 5 years ago

Put bookClone in function.

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

Answer this question