I want model to turn to part it’s tweening to but it won’t
Script:
--\\ Services
local TweenService = game:GetService("TweenService")
--\\ Variables
local module = {}
function module.TweenMob(Goal: CFrame, Mob)
local Start = Mob.Model.PrimaryPart.CFrame
local TimeForTween = module.GetDurationFromWalkspeed(Start, Goal, Mob.Model:GetAttribute("Speed"))
if not TimeForTween then
return -- Useless as hell but
end
local tweenInfo = TweenInfo.new(
TimeForTween,
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut
)
local NewTween = TweenService:Create(Mob.Model.PrimaryPart, tweenInfo, {CFrame = Goal})
NewTween:Play()
NewTween.Completed:Wait()
end
return module
GetDurationFromWalkspeed just gets tween length so I don’t think it’s needed
Script that creates CFrames spots, which I used from suphi’s tower defense thing
local self = {}
function self.initialize()
self.StepStuds = 3
self.SubSteps = 10
self.SubStepsStuds = self.StepStuds / self.SubSteps
self.Parts = workspace.Map.Path.Waypoints:GetChildren()
table.sort(self.Parts, function(a, b)
return a.Name < b.Name
end)
self.Positions = table.create(#self.Parts)
for index, part in self.Parts do
table.insert(self.Positions, part.Position)
end
local cframe = CFrame.lookAt(self.Positions[1], self.Positions[2])
self.CFrames = {cframe}
for index=2, #self.Positions do
local TargetPos = self.Positions[index]
local direction = TargetPos - cframe.Position
while direction.Magnitude > self.SubStepsStuds do
cframe = CFrame.lookAlong(cframe.Position + direction.Unit * self.SubStepsStuds, direction)
table.insert(self.CFrames, cframe)
direction = TargetPos - cframe.Position
end
end
for index, cFrame in self.CFrames do
local NewPart = Instance.new("Part")
NewPart.Shape = Enum.PartType.Ball
NewPart.Size = Vector3.one*0.5
NewPart.Anchored = true
NewPart.CanQuery = false
NewPart.CanCollide = false
NewPart.CanTouch = false
NewPart.CFrame = cFrame
NewPart.Parent = workspace
end
end
return self