Vector3 position random

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to make a system where you buy a part for coins. I want to weld the part to the player’s hand.

  1. What is the issue? Include screenshots / videos if possible!

The issue is that when I buy a part the position is completely random.


A picture when I have bought 100 parts and they are everywhere completely random

script.Parent.MouseButton1Click:Connect(function()
	local Rep = game:GetService("ReplicatedStorage")
	local item = Rep:WaitForChild("Tools")
	local items = item:WaitForChild(script.Parent.Parent.ItemName2.Value)
	local price = script.Parent.Parent.Price
	local player = script.Parent.Parent.Parent.Parent.Parent.Parent
	local stats = player:WaitForChild("leaderstats")
	local character = player.Character
		print(items)
	
	if stats.Scoins.Value >= price.Value and items then
		stats.Scoins.Value = stats.Scoins.Value - price.Value
		local clonedItem = items:Clone()
		clonedItem.Parent = character
		clonedItem.CFrame = character.RightHand.CFrame * CFrame.Angles(0,0,math.rad(90))
		clonedItem.Position = character.RightHand.Position * Vector3.new(1,1,0)
		
		local weld = Instance.new("WeldConstraint")
		weld.Parent = clonedItem
		weld.Part0 = clonedItem
		weld.Part1 = character.RightHand
	end
end)

I’ve tried with a CFrame but that didn’t work either

Use a Motor6D to attach an object to a character’s body part. WeldConstraints don’t let you adjust the position while Motor6D’s have a C0 and C1 to modify the CFrame relative to the attached part.

2 Likes