In this script I am trying to spawn a part on my MousePosition. this part then rotates with the LookVector of my HumanoidRootPart (HRP), which makes the wall rotate away from your character on the place you clicked
The issue im facing is that the part is rotating on the y axis (Up and down, creates more of a slope then a wall). Im trying to make it flat and not on an angle. My theory is that since my HRP is above the ground, the angle is meant to “compensate” for it. But I have no idea how to fix it.
*This is done in a local script
local tool = script.Parent.Parent
local player = game:GetService("Players").LocalPlayer
local RSF = game:GetService("ReplicatedStorage")
local mouse = player:GetMouse()
local HRP = player.Character.HumanoidRootPart
local function WallSpawn()
local MousePosition = mouse.hit
local MousePosY = MousePosition.Y
local MousePosX = MousePosition.X
local MousePosZ = MousePosition.Z
local wall = RSF.Wall:Clone()
wall.Parent = workspace
wall.CFrame = CFrame.new(MousePosX,MousePosY,MousePosZ)
local lv = HRP.CFrame.LookVector
wall.CFrame = MousePosition + lv
task.wait(10)
for i = 1,10 do
wall.Transparency += 0.2
wait(0.33)
wall:Destroy()
end
end
tool.Activated:Connect(function()
WallSpawn()
end)
Thank you for your help