Change value in table

Hello, I am trying to change the value of Number which is in the table ( table ) only if the part becomes transparency = 0. Except that it doesn’t work and I don’t understand why, I made some script to show you

local part = workspace.Part
local tables = {["Number"] = 45;}

if part == 0 then
	tables["Number"] = tables["Number"] + 6
end

-- or 

if part == 0 then
	tables.Number = tables.Number + 6
end

Can u help me please ?

the issue with your script is that you are checking if part is equal to 0, which means that part should be a number and be exactly equal to 0. I assume that you meant to check if the transparency of the part is equal to 0 instead. Here’s an updated script that should probably work:

local part = workspace.Part
local tables = {["Number"] = 45;}

if part.Transparency == 0 then
    tables["Number"] = tables["Number"] + 6
end

-- or 

if part.Transparency == 0 then
    tables.Number = tables.Number + 6
end

1 Like

Thanks you very much for the help.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.