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

Change CFrame Y position ? (Answered)

The script is supposed to clone a model to the Workspace and position and rotate itself to be the position of the player and face the direction the player is looking.

However it spawns too high on the Y-Axis and I need to set it to 2.2 on the Y-Axis in the world (not add or decrease to its current CFrame)

I am just confused how to do this and have tried loads of different things, help would be greatly appreciated.

local freekickwall = game.ServerStorage.FreeKickWall:Clone()
freekickwall.Parent = game.Workspace

freekickwall:SetPrimaryPartCFrame(Character.HumanoidRootPart.CFrame + Character.UpperTorso.CFrame.lookVector)

(EDITED) Answered with the help of radusavin366 and my friend InedibleGames

local freekickwall = game.ServerStorage.FreeKickWall:Clone()
freekickwall.Parent = game.Workspace
local humframe = Character.HumanoidRootPart.CFrame
local inedcalc = humframe.p.Y - 2.2
humframe = humframe - Vector3.new(0, inedcalc, 0)
freekickwall:SetPrimaryPartCFrame(humframe + Vector3.new(Character.HumanoidRootPart.CFrame.lookVector.X, 0, Character.HumanoidRootPart.CFrame.lookVector.Z))

1 answer

✓ Accepted answer

So from all I understand, everything works fine but the block or whatever spawns too high? You could do:

local freekickwall = game.ServerStorage.FreeKickWall:Clone()
freekickwall.Parent = game.Workspace

local humframe = Character.HumanoidRootPart.CFrame

local pos = Vector3.new(humframe.X, 2.2, humframe.Z)

local kickwallpos = CFrame.new(pos, humframe.lookVector

freekickwall:SetPrimaryPartCFrame(kickwallpos)

7 comments

0

So CFrame.humframe.Y? Not CFrame.Y? That could come in handy

0

Wait... not CFrame.humframe but CFrame humframe without the dot?

0

No, "local humframe = Character.HumanoidRootPart.CFrame" and "humframe.Y = 2.2" are separate statements so not dots, editing to make it clear.

0

Thanks for the answer! It comes with an error "Y cannot be assigned to" on line 4

0

edited again

0

I edited my answer, it was a lot more complicated, thanks for the help though you helped come to the solution !

0

no problem :)

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