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

Help with Instance.new Positioning?

Trying to make a part be where the characters torso is. No errors.

Player = game.Players.LocalPlayer
Character = Player.Character

local Torso = Character:WaitForChild("Torso")
while wait(.1) do
	
	local Ball = Instance.new("Part")
	Ball.Position = Torso.Position
end

3 answers

Well if your Torso is in motion, then a While loop would have to be irrelevant, because of Ball.Position = Torso.Position it's gained an old information, because Torso is outside the loop.

Do use RenderStepped instead.

wait(1)
Player = game.Players.LocalPlayer
Character = Player.Character

local Torso = Character:WaitForChild("Torso")
local Ball = Instance.new("Part")

game:GetService'RunService'.RenderStepped:connect(function()
    Ball.Position = Torso.Position
end)


1 comment

0

Did not work.

Alright im assuming that this is Inside of a local script.

I will just fix this, and PM me on roblox or add a comment here asking for an explanation Im tired right now so I am just going to try and help you to get this done.

Player = game.Players.LocalPlayer
Character = Player.Character

local Torso = Character:WaitForChild("Torso")
while wait(.1) do

    local Ball = Instance.new("Part")
    Ball.Position = Torso.Position
end

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character
local torso = char:FindFirstChild("Torso")

local ball = Instane.new("Part")
ball.FormFactor = Enum.Sphere -- Im thinking this is what it is if not please correct me

function pos()
ball.Position =CFrame.new( torso.Position.X+1, torso.Position.Y, torso.Position.Z)
end
while wait(.1) do
pos()
end

I believe this should work, as it fires a function that litteraly grabs the torsos' X,Y, Z positions and adds a +1 to its X position, so that it is I believe 1 stud in front of you.

If it does not work tell me!

Try this:

Ball.Parent = game.Workspace
Ball.CFrame = Torso.CFrame

3 comments

0

Did not work

0

try again

0

im four upvotes away from being able to down vote this.

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