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

Why won't the weld always be created in front of the player ?

I've made a script that create a circle in front of the player that follows him (it stays in front of him). However, when the player turns around, the circle isnt in front of the player anymore, it's always pointing in the same direction

Here is the script :

game.ReplicatedStorage.RemoteEvent.OnServerEvent:connect(function(player)
	local circle = Instance.new("Part", game.Workspace) -- I didnt change the size of the part, so basically, it's not a circle (but with some decals it will become one)
	local weld = Instance.new("ManualWeld", circle)
	
	circle.Size = Vector3.new(1.5,1.5,0.01)
	circle.Anchored = false
	circle.CanCollide = false
	circle.Transparency = 1
	weld.Part0 = circle
	weld.Part1 = player.Character.HumanoidRootPart
	weld.C0 = circle.CFrame
	weld.C1 = player.Character.HumanoidRootPart.CFrame * CFrame.new(1.35,1.25,-2.75)
end)

1 answer

✓ Accepted answer

This is because you’re forgetting a very crucial piece of the formula whilst welding. The CFrame was set, meaning the object will stay in the place it was asked to. There is a method used tie the CFrame of an object to mimic the other, in this case, the lookVector of the Character.

This can easily be fixed by writing

Weld.C0 = circle.CFrame:Inverse()
Weld.C1 = HumanoidRootPart.CFrame:Inverse() * CFrame.new()

I do suggest you set the CFrame of the circle to be ahead of the Character before setting the Objects CFrame, I could break

Hope this fixes your issue

2 comments

0

good job teaching people about inverse +1

0

Oh, thanks;) I’ll return the favour

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