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

How do you change only the position of 1 axis?

I'm having difficulty on this one, I was wanting to change only the y's axis.

Main help part of script:

local part = Instance.new("Part", workspace[plr.Name].Torso)
part.CanCollide = false
part.Anchored = true
part.Size = Vector3.new(1, 1, 1)
part.Position = Vector3.FromAxis(Enum.Axis.Y + 10) -- ?
-- (or)
part.Position = Vector3.FromAxis(Enum.Axis.Y(Enum.Axis.Y + 10)) -- ?

Whole script:

local plr = game.Players.LocalPlayer
wait(2)
local part = Instance.new("Part", workspace[plr.Name].Torso)
part.CanCollide = false
part.Anchored = true
part.Size = Vector3.new(1, 1, 1)
part.Position.Y = part.Position.Y + 5
local mesh = game.ReplicatedStorage.Pet
mesh:Clone().Parent = part
local direction = CFrame.new(part.Position, plr.Character['Left Leg'].Position).lookVector
local increment = direction * 4
while true do
	wait()
	part.CFrame = game.Workspace[plr.Name]['Torso'].CFrame + (direction * increment) + Vector3.new(-5, 0, 0)
	part.Rotation = game.Workspace[plr.Name]['Torso'].Rotation + (direction * increment) + Vector3.new(-1, -2, increment)
end

I would appreciate any help.

1 answer

How are you trying to position your part? If you wanted to position it 10 studs above the torso, it would be something like:

part.CFrame = CFrame.new(torso.Position + Vector3.new(0,10,0))

where you would set the torso variable to the player's torso.

3 comments

0

This script is for a pet that hovers over your shoulder, Here, i'll add the whole script,

0

I'm not sure what you are trying to do with line 7, seeing as you replace the part's CFrame almost instantly afterwards.

0

I'm trying to make it higher above the shoulder. Because when I run the game, it would be directly in my arm, So it's not even hovering above my shoulder.

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