Thank you for reading Error code:Vector3 expected, got number) Script:
local player = game.Players.LocalPlayer local mouse = player:GetMouse() mouse.KeyDown:connect(function(key) if key == "q" then local torso = workspace:FindFirstChild(player.Name) local part = game.ReplicatedStorage.Part:Clone() part.Parent = game.Workspace part.Position = torso.UpperTorso.Position + 10 wait(5) end end)
In line 9 you are trying to add a number to a vector3 value (torso.UpperTorso.Position), which you can't.
A vector3 is a property commonly used for position, rotation, velocity,etc. It consist of three coordinates: X, Y and Z.
To create a vector value you can use Vector3.new(x,y,z), and you can add this value to the vector3 of your player, so you might want to change line 9 for this code:
part.Position = torso.UpperTorso.Position + Vector3.new(0,0,5)
This will create a part 5 studs away from the uppertorso of your character. But if you use this right away you might notice it isn't positioning the block exactly at the front of your character. That's because vector3.new(x,y,z) won't give you the current rotation of your player. So you'll want to use CFrame.lookVector, which basically creates a vector3 poiting 1 stud in the direction a block is facing. You can multiply this vector by any number to increase the distance it will spawn at. Try replacing line 9 again with the following code:
part.Position = torso.UpperTorso.Position +(torso.CFrame.lookVector*5)
You might want to learn more about C and Vector3 in the future, here are some links from roblox API to help you: CFrame Vector3