Im trying to make a dialog so everytime i press the button it adds 1 to a value but that value doesnt seem to change I know its a pretty dumb question but I cant find anywhere what I did wrong and I its been a while since I worked on a game.
it does work for the first “if” when the value == 1 but when it goes to 2 it just repeats 1
local TextLabel = script.Parent:WaitForChild("Gradient"):WaitForChild("TextHolder")
local Sound = TextLabel.Typewriter
local Button = TextLabel.Parent.Button
local Replace = TextLabel.Parent.Image
local Clicked = 0
wait(1)
local function typewrite(object,text,length)
for i = 1,#text, 1 do
Sound:Play()
object.Text = string.sub(text, 1, i)
wait(length)
end
end
if Button.MouseButton1Up then
Clicked = Clicked +1
end
Button.MouseButton1Up:Connect(function()
if Clicked == 1 then
Button.Visible = false
Replace.Visible = true
typewrite(TextLabel, "it looks like the door is locked", 0.05)
Button.Visible = true
Replace.Visible = false
elseif Clicked == 2 then
Button.Visible = false
Replace.Visible = true
typewrite(TextLabel, "maybe there is a key somewhere here", 0.05)
Button.Visible = true
Replace.Visible = false
elseif Clicked == 3 then
script.Parent:Destroy()
end
end)