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

my part won't transparent even if the value is 1?

Hello, How do I fix my script? I made a script where if you press "r" it would add increase a value by one (it is an intvalue by the way) so in the script it would do if the value were 1 then a part will become transparent but it doesn't exactly seem to work

local camera = game.Workspace.VehicleSeat
local value = camera.Value.Value

if value == 1 then do
	game.Workspace.p1.Transparency = 1
	wait(1)
end
end

1 answer

✓ Accepted answer

Your script will only check the Value once, which means that it's not going to detect when the Value is 1 unless it's 1 when the script starts. Try using the Changed event to check the Value whenever it changes.

local camera = game.Workspace:WaitForChild("VehicleSeat")
local value = camera:WaitForChild("Value")
local p1 = Workspace:WaitForChild("p1")

-- if this doesn't print to the output, then all the variables listed above weren't there. 
print("Found all needed parts") 

value.Changed:connect(function()
	-- if this doesn't print then the value isn't changing.
	print("Value changed to "..value.Value) 
	if value.Value == 1 then -- Remove do, you don't need that. 
	    p1.Transparency = 1
	    wait(1)
	end
end)

1 comment

0

wow thanks

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