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

LocalScript and Weld CFrame question?

Asked by
wazap 100
10 years ago
repeat wait() until game.Players.LocalPlayer.Character and
game.Players.LocalPlayer.Character:FindFirstChild"Torso"
local torso = game.Players.LocalPlayer.Character.Torso
local weld = Instance.new("Weld", torso)
local mouse = game.Players.LocalPlayer:GetMouse()
weld.Part0 = torso
weld.C0 = CFrame.new(0,0,.5)
local part = Instance.new("Part", workspace)
part.Anchored = true
weld.Part1 = part

mouse.Move:connect(function()
    print('fire', weld.C0)
    local dir = (mouse.Hit.p-torso.Position).unit
    weld.C0 = torso.CFrame:inverse()*CFrame.new(torso.Position+dir*4, torso.Position+dir*9)
end)

Here's my code. What happens: The print statement prints out the weld's CFrame every time I move the mouse What doesnt happen: The actual bricks dont move at all.

What am I doing wrong?

Answer this question