How to make a Object Spawn in the Direction the Player is Looking

Fixed code, sorry for the inconvenience:

--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

--//Controls
local forwardDistance = 50
local tweeninfo = TweenInfo.new(
	1,	
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

--//Functions
ReplicatedStorage.Remotes.IceWall.OnServerEvent:Connect(function(plr)
	local char = plr.Character

	if not char then
		return
	end

	local clone = ReplicatedStorage.IceLeftWall:Clone()
	clone.CFrame = char.PrimaryPart.CFrame + char.PrimaryPart.CFrame.LookVector * forwardDistance + -char.PrimaryPart.CFrame.RightVector * 40
	clone.CFrame *= CFrame.fromEulerAngles(0, math.rad(-90), 0)
	clone.Parent = char

	local clone2 = ReplicatedStorage.IceRightWall:Clone()
	clone2.CFrame = char.PrimaryPart.CFrame + char.PrimaryPart.CFrame.LookVector * forwardDistance + char.PrimaryPart.CFrame.RightVector * 40
	clone2.CFrame *= CFrame.fromEulerAngles(0, math.rad(90), 0)
	clone2.Parent = char

	local leftWallTween = TweenService:Create(clone, tweeninfo, {Position = clone.Position + clone.CFrame.LookVector * 30})
	leftWallTween:Play()

	local rightWallTween = TweenService:Create(clone2, tweeninfo, {Position = clone.Position + clone.CFrame.LookVector * 30})
	rightWallTween:Play()
	rightWallTween.Completed:Wait()

	clone:Destroy()
	clone2:Destroy()
end)
3 Likes

@Slac3r

Yes, I saw your ping, im testing it out

And it works perfectly! Thank you so much for the help!