Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

TweenService gives me error about a type mismatch?

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****

2 comments

0

Line 17: local tween = tweenService:Create(CFrameValue, info, {Value = CF})

0

Line 28: tweenModel(Ship, Nodes:FindFirstChild("Node" .. i))

1 answer

✓ Accepted answer

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!

2 comments

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

0

use tweenModel(Ship, Nodes:FindFirstChild("Node" .. i).CFrame) instead

This discussion is preserved as it was. New answers, comments, and votes are closed.