Nevermind. I forgot to read it carefully. So you are trying to display a ratio, right?
Edit, because I couldn’t make more than 3 posts:
What I know is the math inside the script isn’t right. I see you are trying to divide the value of the like by the dislikes value. It doesn’t come out as a ratio. It comes out more like a percentage, I guess.
In this case, you might want to do some debugging to figure out what the script thinks likeRatio and dislikeRatio equal. Try inserting a print function to figure out what they are.
This is because of how you’re creating your ratio, you aren’t making your ratios properly. You basically have to add up the likes and dislikes, and then the like/dislike ratio would be likes/dislikes divided by your total amount of votes
local likes = 10
local dislikes = 1
local votes = likes + dislikes
local likeRatio = likes / votes
local dislikeRatio = 1 - likeRatio
--...
if tostring(likeRatio) == 'inf' then
likesBar:TweenSize(UDim2.new(1,0,1,0))
dislikesBar:TweenSize(UDim2.new(0,0,1,0))
elseif tostring(dislikeRatio) == 'inf' then
likesBar:TweenSize(UDim2.new(0,0,1,0))
dislikesBar:TweenSize(UDim2.new(1,0,1,0))
else
likesBar:TweenSize(UDim2.new(likeRatio,0,1,0))
dislikesBar:TweenSize(UDim2.new(dislikeRatio,0,1,0))
end
EDIT: not sure why I didn’t think of this before but you can also just clamp each of the values to avoid the if statement entirely, that way you don’t have to rely on strings:
local likes = 10
local dislikes = 1
local votes = likes + dislikes
local likeRatio = math.clamp(likes / votes, 0, 1)
local dislikeRatio = math.clamp(1 - likeRatio, 0, 1)
likesBar:TweenSize(UDim2.new(likeRatio,0,1,0))
dislikesBar:TweenSize(UDim2.new(dislikeRatio,0,1,0))