Ok, I’ll try to make this really easy to understand. I want to tween a rig (model) to a certain location (model). Here’s my code (ignore the top part).
local tweenService = game:GetService("TweenService")
local function appear()
-- Define variables
local stand = workspace.Stand
local firstLoc = stand.Spawn
local spots = stand.Spots
local rigs = game.ReplicatedStorage:WaitForChild("Rigs")
-- Select a rig --
local rigNum = math.random(1,3)
local rigType
for i, rig in ipairs(rigs:GetChildren()) do
if i == rigNum then
rigType = rig
end
end
-- Select a location --
for i, newLoc in ipairs(spots:GetChildren()) do
if newLoc:GetAttribute("Taken") == false then
-- Spot is open, spawn rig --
newLoc:SetAttribute("Taken", true)
local newRig = rigType:Clone()
newRig.Parent = workspace
newRig:PivotTo(firstLoc:GetPivot())
-- Get item's pivots --
local rigPivot = newRig:GetPivot()
local locPivot = newLoc:GetPivot()
-- Find magnitute and time
local mag = (rigPivot.Position - locPivot.Position).magnitude
local duration : number = mag / 8
-- Make tween info --
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local goal = {rigPivot = locPivot}
-- Make tween and play --
local tween = tweenService:Create(newRig, tweenInfo, goal)
tween:Play()
tween.Completed:Wait()
end
end
end
return appear
The table “goal” requires you to put in properties that you want to tween with their final value. “rigPivot” can’t be tweened because it’s simply not an existent property. Read the documentation for more information on how to use TweenService:
You cant tween the pivot of the model since it isn’t a property of the model. Try tweening the primary part of the model [Once you weld all the parts of the model to it](e.g. the hmr)
local duration : number = mag / 8
-- Make tween info --
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local goal = {CFrame = locPivot}
-- Make tween and play --
local tween = tweenService:Create(newRig.PrimaryPart, tweenInfo, goal)
tween:Play()
tween.Completed:Wait()
If you dont want to use this to try moving the rig’s humanoid to locPivot.Position
You cannot use variables for property names, and you cannot change the pivot variables of a model, use CFrame instead. Here is a code snippet if you are looking to tween a model:
local tweenService = game:GetService(“TweenService”)
local info = TweenInfo.new()
local function tweenModel(model, CF)
local CFrameValue = Instance.new(“CFrameValue”)
CFrameValue.Value = model:GetPivot()