Hey all! I’m trying to figure out why my part of my script won’t run as intended. This is what it looks like.
local Part = game.Workspace.MyPart
local function BestFunction()
local BestNumber = 15
local FavoriteNumber = 10
print(BestNumber+FavoriteNumber)
end
Part.Transparency = 0.4
local function Ghost()
if Part.Transparency == 0.4 then
print("What")
end
end
BestFunction()
Ghost()
It prints out the “25” however it doesn’t print out “What” even though the part transparency is 0.4. Can anyone help?
When dealing with decimals if you learnt computer science it’s a floating point number and the computer basically stores it as 0.40000009 from what I remember.
Basically equality is unreliable when decimals come into play.
Better to use > or < instead but there is also the method below which should work.
local Part = workspace.MyPart--Or script.Parent and move in part
local function BestFunction()
local BestNumber = 15
local FavoriteNumber = 10
print(BestNumber+FavoriteNumber)
end
Part.Transparency = 0.4
local function Ghost()
print(Part.Transparency)
if Part.Transparency == 0.4 then
print("What")
end
end
BestFunction()
Ghost()