Hello everybody, as again, i'm making a doors game and i have encountered an error.
This is the error:
14:00:25.785 Unable to cast Instance to CoordinateFrame - Server - Monster:14 14:00:25.785 Stack Begin - Studio 14:00:25.785 Script 'ServerScriptService.Server.Monster', Line 14 - Studio - Monster:14 14:00:25.785 Stack End - Studio
This is the code i believe responsible.
function monsterModule.lerpTo(m, targ)
local alp = 0
local speed = 50
local dist = (m.PrimaryPart.Position - targ.Position).Magnitude
local relativeSpeed = dist / speed
local startC = m.PrimaryPart.CFrame
local loop = nil
local reachedTarg = Instance.new('BindableEvent')
loop = monsterModule.runServ.Heartbeat:Connect(function(del)
local goalC = startC:Lerp(targ, alp)
m:PivotTo(goalC)
alp += del / relativeSpeed
if alp >= 1 then
loop:Disconnect()
reachedTarg:Fire()
end
end)
reachedTarg.Event:Wait()
end
If you wish to answer, please do! Any help is appreciated!

1 comment
If thats not enough information for you, here's the full code:local monsterModule = {} monsterModule.runServ = game:GetService('RunService') function monsterModule.lerpTo(m, targ) local alp = 0 local speed = 50 local dist = (m.PrimaryPart.Position - targ.Position).Magnitude local relativeSpeed = dist / speed local startC = m.PrimaryPart.CFrame local loop = nil local reachedTarg = Instance.