Help with a basic script

Hi,

This script doesn’t work. When the guy is suddenly enabled it doesn’t make this visible. I hope you can help me.

if script.Parent.Parent.Parent.Enabled == true then

wait(7.5)

script.Parent.Visible = true

end

from,
file

You’ll need to connect it with a Changed or GetPropertyChangedSignal function or add it to a loop.

Here’s a fixed code:

local gui = script.Parent.Parent.Parent

gui:GetPropertyChangedSignal('Enabled'):Connect(function()
if gui.Enabled then
wait(7.5)
script.Parent.Visible = true
end
end)

Not sure if this works correctly

1 Like

GetPropertyChangedSignal requires a string property to change, I’m pretty sure you can’t do it like that

Plus you’re attempting to pass a non-defined parameter in the function

local Gui = script.Parent.Parent.Parent

--Enabled is the property we want to detect whenever it changes
Gui:GetPropertyChangedSignal("Enabled"):Connect(function()
    if Gui.Enabled == true then
        wait(7.5)
        script.Parent.Visible = true
    end
end)

1 Like
Gui=script.Parent.Parent.Parent
Gui.Changed:Connect(function(x)
    if x=="Enabled" and Gui.Enabled==true then
        script.Parent.Visible = true
    else
        script.Parent.Visible = false
    end
end)

this worked thanks a whole lot! :slight_smile:

1 Like