Unable to cast value to funtion

  1. What do you want to achieve?
    I want to make an “Thirst Bar”

  2. What is the issue?
    It gives me an error: “Unable to cast value to function”

  3. What solutions have you tried so far?
    I tried looking on youtube and developer forum but I can’t find the solution.

local Player = game.Players.LocalPlayer
local Thirst = Player:WaitForChild("Thirst")

local BarExterior = script.Parent
local BarInterior = BarExterior.BarInterior

local function UpdateThirst()
	local CurrentValue = Thirst.Value
	local Formula = math.clamp(CurrentValue/100, 0, 1)
	
	BarInterior:TweenSize(UDim2.new(Formula, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0,8, true)
end

UpdateThirst()
Thirst.Changed:Connect(function()
	UpdateThirst()
end)

This is the code

What part of the code is exactly giving this issue :nerd: Like what line :nerd:

Line 11:

BarInterior:TweenSize(UDim2.new(Formula, 0, 1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0,8, true)

Can you print:

Formula

Maybe thats the value thats not correct

Yes already did that everything is alright with Formula.

Give me a second, It’s just that I dont use :TweenSize() since it has more limitations than tween service so let me go and read the documentation again.

Umm actually sir you typed 0,8 instead of 0.8, You see if you put a comma you are setting them as 2 values instead of 0.8 :nerd: You need to change it

Oh, didn’t saw that haha, thanks for your time!

1 Like