I just want to tween a model to move to random spots in an area, and have it face the location is moves to. I can get it to move if I change the code around a bit, but if I try adding rotation to the CFrame I start getting problems all over.
Right now I get this error
[Workspace.Map.Home.PetHouse.Cat.Body.Script:17: attempt to call a table value]
Here is the code
local character = script.Parent.Parent
local base = character.Parent.Base
local sizeX, sizeZ = base.Size.X/2, base.Size.Z/2
local tweenService = game:GetService("TweenService")
local info = TweenInfo.new()
local xf = character.PrimaryPart.CFrame.X
local zf = character.PrimaryPart.CFrame.Z
local pos = CFrame.new((xf + math.random(-sizeX, sizeX)), character.PrimaryPart.CFrame.Y, (zf +math.random(-sizeZ, sizeZ)))
local function tweenModel(model, CF)
local rot = CFrame.new(Vector3.new(CF), Vector3.new(CF))
local Properties = {CFrame = CFrame(CF, rot)}
--Properties.CFrame = CFrame(CF, rot)
local tween = tweenService:Create(model, info, Properties)
tween:Play()
end
while true do
wait(2)
tweenModel(character.PrimaryPart, pos)
end
I can NOT figure out what it wants from me. Any help here would really be appreciated it’s been about an hour and a half and I can’t seem to find anyone else who’s had this issue.