Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

TweenService gives me error about a type mismatch?

Asked by 4 years ago
Edited 4 years ago
local Ship = script.Parent
local Nodes = workspace.ShipNodes
local ShipNodes = workspace.ShipNodes:GetChildren()

local tweenService = game:GetService("TweenService")
local info = TweenInfo.new()

local function tweenModel(model, CF)
    local CFrameValue = Instance.new("CFrameValue")
    CFrameValue.Value = model:GetPrimaryPartCFrame()

    CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
        model:SetPrimaryPartCFrame(CFrameValue.Value)
    end)

    local tween = tweenService:Create(CFrameValue.Value, info, {Value = CF})
    tween:Play()

    tween.Completed:Connect(function()
        CFrameValue:Destroy()
    end)
end


while wait() do
    for i = 1, #ShipNodes do
        tweenModel(Ship, Nodes:FindFirstChild("Node" .. i))
        wait()
    end
end

**** 22:36:59.450 - TweenService:Create property named 'Value' cannot be tweened due to type mismatch (property is a 'CoordinateFrame', but given type is 'Instance') 22:36:59.451 - Stack Begin 22:36:59.452 - Script 'Workspace.Ship.Script', Line 17 - local tweenModel 22:36:59.452 - Script 'Workspace.Ship.Script', Line 28 22:36:59.452 - Stack End****

0
Line 17: local tween = tweenService:Create(CFrameValue, info, {Value = CF}) TheDev321 37 — 4y
0
Line 28: tweenModel(Ship, Nodes:FindFirstChild("Node" .. i)) TheDev321 37 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

Looks like you cannot tween a CFrameValue, you can use a part in nil and then CFrame it, then make the model follow it

local Ship = script.Parent
local Nodes = workspace.ShipNodes
local ShipNodes = workspace.ShipNodes:GetChildren()

local tweenService = game:GetService("TweenService")
local infoArray = {
1, --// Duration of the tween
Enum.EasingStyle.Style, --// style
Enum.EasingDirection.In, --// Easing Direction
false,
0,
false
} --// Info

local info = TweenInfo.new(unpack(infoArray))

local function tweenModel(model, CF)
    local Part = Instance.new("Part")
    Part.CFrame = model:GetPrimaryPartCFrame()

    Part:GetPropertyChangedSignal("CFrame"):Connect(function()
        model:SetPrimaryPartCFrame(Part.CFrame)
    end)

    local tween = tweenService:Create(Part, info, {CFrame = CF})
    tween:Play()

    tween.Completed:Connect(function()
        Part:Destroy()
    end)
end


while wait() do
    for i = 1, #ShipNodes do
        tweenModel(Ship, Nodes:FindFirstChild("Node" .. i))
        wait()
    end
end

What we basically do is make a part and Tween it, and listen for every time its CFrame changes, so the model follows it.

If this answered your question mark it as the answer!

0
19:06:54.706 - TweenService:Create property named 'CFrame' cannot be tweened due to type mismatch (property is a 'CoordinateFrame', but given type is 'Instance') 19:06:54.706 - Stack Begin 19:06:54.707 - Script 'Workspace.Ship.Script', Line 26 - local tweenModel 19:06:54.707 - Script 'Workspace.Ship.Script', Line 37 19:06:54.707 - Stack End TheDev321 37 — 4y
0
use tweenModel(Ship, Nodes:FindFirstChild("Node" .. i).CFrame) instead maumaumaumaumaumua 628 — 4y
Ad

Answer this question