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

Weld not sticking part to specified position?

Asked by 8 years ago

I tried to make a yellow ball which i stored in lighting hover over the player's head when they touch a brick, however, the ball welds to a strange place several studs behind and under the player's torso. Here's my code:

brick = script.Parent

brick.Touched:connect(function(h)
    ishuman = h.Parent:FindFirstChild('Humanoid')
    if ishuman then
        p = game.Lighting.a:Clone()
        p.Parent = game.workspace

        s = Instance.new("Weld")
        s.Parent = h.Parent.Torso
        s.Part0 = h.Parent.Torso
        s.C0 = h.Parent.Torso.CFrame:inverse()
        s.Part1 = p
        s.C1 = p.CFrame:inverse()
        p.CFrame = h.Parent.Torso.CFrame * CFrame.new(0,3,0)
    end
end)
0
Why did you store it in lighting? This is 2016 not 2008 Why not use ReplicatedStorage? User#5748 20 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

You can try using the toObjectSpace and toWorldSpace CFrame methods to achieve the result your looking for. CFrames are picky.. and the simplest things are hard to do. So I wouldn't be of much help.

Ad

Answer this question