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))
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)