TweenService:Create property named 'Material' cannot be tweened due to type mismatch (property is a 'int', but given type is 'token')

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?

I wanted to tween a part and change his color and material using TweenService.

  1. What is the issue?

There is a error that`s saying:
" TweenService:Create property named ‘Material’ cannot be tweened due to type mismatch (property is a ‘int’, but given type is ‘token’)"

  1. What solutions have you tried so far?

I tried to find a solution here, but some of developers, which also had this problem, had a different error(like they tried to tween Position with CFrame, not Vector3 and etc).

Here is the image of error:

Here is the code:

local TweenService = game:GetService(“TweenService”)

local part = script.Parent

local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
-1,
false,
0
)

local goal = {
Color = Color3.new(1, 0, 0),
Material = Enum.Material.Neon
}

local tween = TweenService:Create(part, tweenInfo, goal)

tween:Play()

Also i tried to change material using different styles of code:

local goal = {}
goal.Material = Enum.Material.Neon

But the result is the same:(

Since Enums are not actually numerals(and it would actually be awkward if you tried to tween through the fixed list of materials), you cannot really use it for tweening. You might need a different way of switching the material, whether it is midway through or right at the end of the tween.

1 Like

You cannot tween materials as they are not int(number) values, here’s a fixed version:

local TweenService = game:GetService(“TweenService”)

local part = script.Parent

local tweenInfo = TweenInfo.new(
2,
Enum.EasingStyle.Quad,
Enum.EasingDirection.Out,
-1,
false,
0
)

local goal = {
Color = Color3.new(1, 0, 0),
}

local tween = TweenService:Create(part, tweenInfo, goal)

tween:Play()
part.Material = Enum.Material.Neon

But isn`t the type of material - EnumItem?

Tweening a material is not possible because EnumItems are not numeric(int) values.

You can probably hide the part with tweening then change the material then show the part again.

1 Like

Ok, thanks for the explanation

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.