Hi I was making this script when you touch a part you will be teleported to the spawn location
and this GUI pops up I got the “touch a part to show gui script” in youtube here
i made this local script it detects when the gui visible is equals to true but it did not
work properly
here is the script:
local frame = script.Parent.Frame
local yes = script.Parent.Frame.Yes
local no = script.Parent.Frame.No
local text = script.Parent.Frame.TextLabel
local sound = script.Sound
local sound1 = script.Sound1
local sound2 = script.Sound3
if frame.Visible == true then
print("worked")
sound:Play()
wait(0.7)
text.Visible = true
sound1:Play()
wait(0.7)
sound2:Play()
yes.Visible = true
no.Visible = true
end
there is no errors
i was so confused why it didn’t work
You need to use GetPropertyChangedSignal on the Visible Property to detect it as this only detects once when the script executes
local frame = script.Parent.Frame
local yes = script.Parent.Frame.Yes
local no = script.Parent.Frame.No
local text = script.Parent.Frame.TextLabel
local sound = script.Sound
local sound1 = script.Sound1
local sound2 = script.Sound3
frame:GetPropertyChangedSignal("Visible"):Connect(function()
if frame.Visible then
print("worked")
sound:Play()
wait(0.7)
text.Visible = true
sound1:Play()
wait(0.7)
sound2:Play()
yes.Visible = true
no.Visible = true
end
end)
Or as an alternative method using a Guard Clause
local frame = script.Parent.Frame
local yes = script.Parent.Frame.Yes
local no = script.Parent.Frame.No
local text = script.Parent.Frame.TextLabel
local sound = script.Sound
local sound1 = script.Sound1
local sound2 = script.Sound3
frame:GetPropertyChangedSignal("Visible"):Connect(function()
if not frame.Visible then
return
end
print("worked")
sound:Play()
wait(0.7)
text.Visible = true
sound1:Play()
wait(0.7)
sound2:Play()
yes.Visible = true
no.Visible = true
end)