Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago

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

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

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)
0
wow thanks KatsuneSniper 31 — 7y
Ad

Answer this question