Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you change only the position of 1 axis?

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

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.

0
This script is for a pet that hovers over your shoulder, Here, i'll add the whole script, LennonLight 95 — 6y
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. mattscy 3725 — 6y
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. LennonLight 95 — 6y
Ad

Answer this question