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

How to fix unable to cast string to token error for roblox lua?

I'm getting this error, 12:27:14.234 - Unable to cast string to token, for this script.

local player = game.Players.LocalPlayer
local character = workspace:WaitForChild(player.Name)
local hum = character:WaitForChild("Humanoid")

local upper = script.Parent.HealthUpper
local down = script.Parent
local text = script.Parent.Health

local function updatebar()
	text.Text = "Health: "..hum.Health.." / "..hum.MaxHealth
	upper:TweenSize(UDim2.new(hum.Health / hum.MaxHealth, 0, 1, 0), "out", "Linear", 0.5)
end

updatebar()

hum.Changed:Connect(function()
	updatebar()
end)

That is the full script for health bar. I've never seen this error before. I believe when I clicked the error it took me to line 12 or 13.

2 comments

0

Enum.EasingStyle.Out, Enum.EasingDirection.Linear

0

whut

1 answer

✓ Accepted answer

What you are using here is String Values. The "out" easingstyle isn't an easingstyle, since Lua is sensitive about lower-cases and upper-cases. What you should do is use Enums, and they give you the choices.

local function updatebar()
	text.Text = "Health: "..hum.Health.." / "..hum.MaxHealth
	upper:TweenSize(UDim2.new(hum.Health / hum.MaxHealth, 0, 1, 0), Enum.EasingStyle.Out, Enum.EasingDirection.Linear, 0.5)
end

1 comment

0

Now I get the error, 12:46:31.469 - Out is not a valid EnumItem, for the script

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