Ice Spike End Orientation

Hello! So I have this functioning script that successfully spawns in a set of ice spikes when a player presses a specific button.

The issue is that once everything plays out properly, I do not like the way the ice spikes are all vertical and not tilted at all. I want to change that… I would like to make them slanted facing the opposite direction of the player so it looks like the ice spikes are pointing towards the direction the players used towards.

I tried used .Orientation = (x, y, z) to try and change its end orientation but that isn’t working.

local ice = {}


local setting = {
	MaxHeight = 50,
	MaxWidth = 35,
	MaxParts = 40,
	MaxAngle = 15,
	LastingTime = 5
}
local TS = game:GetService('TweenService')
function ice.Spikes(pos,IgnoreParams)
	local MaxParts = setting.MaxParts
	local MaxHeight = setting.MaxHeight
	local MaxWidth = setting.MaxWidth
	local MaxAngle = setting.MaxAngle
	local SpikePos
	local dist = MaxHeight/MaxParts
	local feather = MaxWidth/MaxParts
	local fmulti = feather
	local dmulti = dist
	local LastingTime = setting.LastingTime
	
	-- | Casting Information
	local raycastParams = RaycastParams.new()
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	raycastParams.FilterDescendantsInstances = {IgnoreParams}
	raycastParams.IgnoreWater = true
	for i = 1, MaxParts do
		
		coroutine.wrap(function()
			local Spike = game.ReplicatedStorage:WaitForChild('Assets').IceSpike:Clone()
			Spike.Parent = workspace
			
			local feathering = math.random(-feather,feather)
			local raycastResult = workspace:Raycast(pos.Position, (pos * Vector3.new(feather,-1,-dist).Unit*20), raycastParams)
			local rotx,roty,rotz = math.random(-MaxAngle,MaxAngle),math.random(-MaxAngle,MaxAngle),math.random(-MaxAngle,MaxAngle)
			
			Spike.CFrame = pos * CFrame.new(feathering,0,-dist)

			
			Spike.Size = Vector3.new(dist*2,dist*2,dist*2)
			Spike.CFrame = Spike.CFrame * CFrame.Angles(0, math.rad(roty),0)
			feather = feather + fmulti/2
			dist = dist + dmulti/2
			local TI = TweenInfo.new(0.25,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0)
			local Prop = {CFrame = Spike.CFrame * CFrame.new(0,1,0)}
			local Prop2 = {CFrame = Spike.CFrame * CFrame.new(0,-1,0)}
			local Tween = TS:Create(Spike,TI,Prop)
			local Tween2 = TS:Create(Spike,TI,Prop2)
			wait()
			Tween:Play()
			wait(0.25)
			Tween2:Play()
			coroutine.wrap(function()
				wait(LastingTime)
				Spike:Destroy()
			end)()
		end)()
		
	end
end
return ice

Any help would be VERY greatly appreciated!

2 Likes

Instead of assigning to the .Orientation property, use CFrame.Angles()

For example, if I wanted to rotate a part 90 degrees along the Y axis, I’d do the following

part.CFrame = part.CFrame * CFrame.Angles(0,math.rad(90),0) 

Angles uses radians, so I did math.rad(90) to convert 90 degrees into radians.

2 Likes