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

Unable to compare two numbers?

Hello, I have an if statement here which is trying to compare the number on the second letter but it is a nil value. I used the type function and in printed that it was a number so any help?

if tonumber(string.sub(v.Name,2)) > total then

BTW total = 0. In the output it prints out attempt to compare number with a nil value.

3 comments

1

So if v. Name is equal to "1234" string.sub(v.Name,2) returns everything past character #2, so it would return "34". Now since your getting an nil value error, either total is somehow nil or v. Name is nil. Try printing total and v. Name, and string.sub(v.Name, 2) and tell me what the results are. Whenever something I made has a weird bug, I print all the values so I can see what variable is

0

if you want to just get the seccond letter you need string.sub(thing,2,2)

0

Lol

1 answer

Here's what I did:

local sides = 6 local radius = 4 for i=1,sides do local s = math.tan(math.rad(180/sides))radius print(s) side = Instance.new("Part") side.Material = "DiamondPlate" side.Parent = game.Players.LocalPlayer.Character.Head side.Anchored = true side.Size = Vector3.new(.1,.1,2s) side.TopSurface = "Smooth" side.BottomSurface = "Smooth" side.BrickColor = BrickColor.Yellow() side.CFrame = side.Parent.CFrame * CFrame.new(0,2,0) * CFrame.Angles(0,math.rad(360/sides*i),0) * CFrame.new(radius,0,0) end

The reason why is that....

1 comment

0

this was ages ago why did u answer

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