Attempt to perform arithmetic (div) on Instance

I want to try a way to fix this error, so this is my script

local Player = game:GetService("Players").LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()

repeat
	wait()
until char:FindFirstChild("UltimateMax")

repeat
	wait()
until char:FindFirstChild("UltimateValue")

local ultvalue = char:FindFirstChild("UltimateValue")
local ultmax = char:FindFirstChild("UltimateMax")

while true do
	wait()
	
	local endSize = UDim2.new(ultvalue / ultmax,0,1,0) -- this line error

	script.Parent.UltimateBar:TweenSize(endSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.5, true)
end
1 Like

You are trying to divide instances

Do this instead:

ultvalue.Value / ultmax.Value (i guess they are values if not then this wont work)

1 Like

Are the instances values? If so, change

Those 2 lines to:

‘’’
local ultvalue = char:FindFirstChild(“UltimateValue”).Value
local ultmax = char:FindFirstChild(“UltimateMax”).Value
‘’’

1 Like

I changed it and there no error but the gui is not tweening

while true do
	wait()
	
	local endSize = UDim2.new(ultvalue / ultmax,0,1,0) -- this line error

	script.Parent.UltimateBar:TweenSize(endSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.5, true)
end

You’re performing the tween every 2 frames.

Increase the yield to match the tween’s length, i.e; task.wait(0.5) at the start of the loop.

is still not tweening idk why , even though the value changed

1 Like

Try:

local Player = game:GetService("Players").LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()

local ultvalue = char:WaitForChild("UltimateValue").Value
local ultmax = char:WaitForChild("UltimateMax").Value

while true do
	task.wait(.5)
	
	local endSize = UDim2.new(ultvalue / ultmax, 0,1,0)

	script.Parent.UltimateBar:TweenSize(endSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.5, true)
end