Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

why won't my function connect and text appear?

I've created a script that, upon click of "ClickyClick", makes a TextLabel gradually increase its transparency and all of my prints work except the text doesn't appear

function ChangeOfMoneyGui(clicker)
	db = 0
	print("function connected")
	if db == 0 then
		db = 1
		print("debounce active")
		local plrg = clicker:FindFirstChild("PlayerGui")
		local mc = plrg.ChangeOfMoney.MoneyChangeFrame.MoneyChange
		local tt = mc.TextTransparency
		local st = mc.TextStrokeTransparency
		visible = false
		if visible == false then
			print("visible = true")
			visible = true
			appear(tt)
			appear(st)
			wait(2)
			disappear(tt)
			disappear(st)
			visible = false
		end
	end
end

game.Workspace.ClickyClick.ClickDetector.MouseClick:connect(ChangeOfMoneyGui)


function appear(transparency)
	print("appear function called")
	for i = 1, 0, .05 do
	transparency = i
	end
end	


function disappear(transparency)
	print("disappear function called")
	for i = 0, 1, .05 do
	transparency = i
	end
end

1 comment

0

messed up on title, function did connect except the text just won't appear

2 answers

✓ Accepted answer

The text doesn't appear because you are never updating its transparency. In the code

function appear(transparency)
    print("appear function called")
    for i = 1, 0, .05 do
    transparency = i
    end
end 

you are only updating the variable transparency and not the actual transparency of the label's text. To make this work, consider using this function

function appear(label)
    print("appear function called")
    for i = 1, 0, .05 do
        label.TextTransparency = i
        label.TextStrokeTransparency = i
        wait()
    end
end 

and calling it by passing the label mc as an argument. Do similarly for disappear. Keep in mind you will want to call wait upon each loop iteration to prevent the text from appearing instantly.

2 comments

0

thanks, worked!

0

No problem

You get the Value of the Transparency and not set it to the new value and you did this loop:

for i = 1, 0, .05 do

this will not decrease i so it gets visible again you need to do the loop like this:

for i = 1, 0, -.05 do

try this :

function appear(object)
	print("appearing")
	for i = 1, 0, -.05 do
		object.TextTransparency = i
		object.Transparency = i
	end
end

function dissappear(object)
	print("dissappearing")
	for i = 0, 1, 0.5 do
		object.TextTransparency = i
		object.Transparency = i
	end
end

function ChangeOfMoneyGui(clicker)
	db = 0
	print("connected")
	if db == 0 then
		db = 1
		print("debounce")
		local plrgs = clicker:FindFirstChild("PlayerGui")
		local mc  = plrgs.ChangeOfMoney.MoneyChangeFrame.MoneyChange
		visible = false
		if visible == false then
			print("visible now")
			visible = true
			appear(mc)
			wait(2)
			dissappear(mc)
			visible = false
			
		end
	end
end

game.Workspace.ClickyClick.ClickDetector.MouseClick:connect(ChangeOfMoneyGui)

This discussion is preserved as it was. New answers, comments, and votes are closed.