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

Change CFrame Y position ? (Answered)

Asked by
xdeno 187
5 years ago
Edited 5 years ago

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

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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)
0
So CFrame.humframe.Y? Not CFrame.Y? That could come in handy OBenjOne 190 — 5y
0
Wait... not CFrame.humframe but CFrame humframe without the dot? OBenjOne 190 — 5y
0
No, "local humframe = Character.HumanoidRootPart.CFrame" and "humframe.Y = 2.2" are separate statements so not dots, editing to make it clear. radusavin366 617 — 5y
0
Thanks for the answer! It comes with an error "Y cannot be assigned to" on line 4 xdeno 187 — 5y
View all comments (3 more)
0
edited again radusavin366 617 — 5y
0
I edited my answer, it was a lot more complicated, thanks for the help though you helped come to the solution ! xdeno 187 — 5y
0
no problem :) radusavin366 617 — 5y
Ad

Answer this question