Hi, im having a problem that this script wont work
it is used so when the timer reaches a certain number a screengui will get enabled
(screengui is disabled on propeties)
thanks you in advance if you helped me
local t = script.Parent.Text -- textlabel
local s = script.Parent.Parent -- screen gui
if s.Enabled == true then
t ="hey"
wait(2)
t = "do you want a secret"
wait(2)
t = "look behind you"
wait(2)
t = "a small door right?"
end
Your problem is the script will run as soon as it’s loaded so if s.Enabled==false then nothing will happen and it doesn’t check again. You can make use of ** GetPropertyChangedSignal** for this. It can trigger a function that will run when the value has changed:
local t = script.Parent.Text -- textlabel
local s = script.Parent.Parent -- screen gui
local function MyFunction()
if s.Enabled == true then
t ="hey"
wait(2)
t = "do you want a secret"
wait(2)
t = "look behind you"
wait(2)
t = "a small door right?"
end
end
s:GetPropertyChangedSignal("Enabled"):Connect(MyFunction)
Why?
If the timer is being run on the server and the player joins a little late then task.wait wouldn’t be synced with the timer unless you write more code to get current time on the timer etc - which is more effort than needed.
EDIT: Never mind I think you meant use task.wait() instead of wait() in the function lol Yes I agree!, I just copied/pasted his original code without editing.
I just tested the script in Studio and it works as expected. Check your code that changes the Enabled value of the giu to make sure it is being enabled.
i cant seem to find the error it still wont work
here is the script for the timer maybe its the problem?
local ScreenGui = script.Parent
local value = 0
local maxValue = 5
local humanoidSeated
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Seated:Connect(function(active, currentSeatPart)
print(active)
if active then
humanoidSeated = true
while value ~= maxValue + 1 do
ScreenGui.Parent.Timer.TextLabel.Text = (value)
task.wait(1)
if not humanoidSeated then break end
value += 1
end
ScreenGui.Enabled = true
else
humanoidSeated = false
value = 0
ScreenGui.Enabled = false
end
end)
That code seems ok.
One thing I noticed in your original script was this line: local t = script.Parent.Text – textlabel
is Text the NAME of the textlabel? if so then you will need to change the values in your function to t.Text=“hey” … change the other t= to t.Text= too