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

Trying to activate script through a click detector, nothing is in output, why?

I am trying to activate this script with a click detector and have been going at it for a few hours with no luck. Nothing is in the output so I am completely lost.

Any help?

local deb = false 

function onClicked(plr) 
		deb = true -- Changes deb to true.
		for i,v in pairs(game.Players:GetPlayers()) do 
		local PlayerGui = v.PlayerGui 
		PlayerGui.Fade.Frame.Visible = true 
		PlayerGui.Fade.Frame.BackgroundTransparency = 0.9 
		wait(0.1) 
		PlayerGui.Fade.Frame.BackgroundTransparency = 0
		wait(3) 
		PlayerGui.Fade.Frame.BackgroundTransparency = 0.1
		wait(0.1)
		PlayerGui.Fade.Frame.BackgroundTransparency = 0.2
		wait(0.1)
		PlayerGui.Fade.Frame.BackgroundTransparency = 0.3
		wait(0.1)
		PlayerGui.Fade.Frame.BackgroundTransparency = 0.4
		wait(0.1)
		PlayerGui.Fade.Frame.BackgroundTransparency = 0.5
		wait(0.1)
		PlayerGui.Fade.Frame.BackgroundTransparency = 0.6
		wait(0.1)
		PlayerGui.Fade.Frame.BackgroundTransparency = 0.7
		wait(0.1)
		PlayerGui.Fade.Frame.BackgroundTransparency = 0.8
		wait(0.1)
		PlayerGui.Fade.Frame.BackgroundTransparency = 0.9
		wait(0.1)
		PlayerGui.Fade.Frame.BackgroundTransparency = 1
		PlayerGui.Fade.Frame.Visible = false 
		end
		deb = false 
		script.Parent.mouseClick:connect(onClicked)
	end

1 answer

✓ Accepted answer

Ok so, regarding your issue with the click detector not working, its because you put the connection within the function itself. Put the line that creates the connection at the bottom of the script and it should fix it up.

I would also recommend for you to use for loops when dealing with transparencies. Instead of having a bunch of lines that increment the backgroundtransparency up, do something like this:

PlayerGui.Fade.Frame.BackgroundTransparency = 0
wait(3)
for i = .1,1,.1
	PlayerGui.Fade.Frame.BackgroundTransparency = i
	wait(.1)
end

This will do what your code above does, but in a much shorter manner. Nobody wants to copy paste out that much code.

1 comment

0

Thank you <3

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