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

Weld not sticking part to specified position?

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)

1 comment

0

Why did you store it in lighting? This is 2016 not 2008 Why not use ReplicatedStorage?

1 answer

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.

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