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

My client side GUI won't work, why?

Here's the code:

function onPlayerEntered (swag)

local GUI = script.Parent.Parent
 GUI.Parent = swag.PlayerGui


wait(5)
GUI.BackgroundTransparency = 0.1
wait(0.1)
GUI.BackgroundTransparency = 0.2
wait(0.1)
GUI.BackgroundTransparency = 0.3
wait(0.1)
GUI.BackgroundTransparency = 0.4
wait(0.1)
GUI.BackgroundTransparency = 0.5
wait(0.1)
GUI.BackgroundTransparency = 0.6
wait(0.1)
GUI.BackgroundTransparency = 0.7
wait(0.1)
GUI.BackgroundTransparency = 0.8
wait(0.1)
GUI.BackgroundTransparency = 0.9
wait(0.1)
GUI.BackgroundTransparency = 1
GUI.Active = false






game.Players.ChildAdded:connect (onPlayerEntered) 

end


 

Doesn't give me errors, but it won't fade like it should.

3 comments

0

Is GUI a screengui or a frame?

0

Frame. It's parented inside of a textlabel, though.

0

I mean, the script is parented inside of a textlabel.

2 answers

✓ Accepted answer

#Updated Your problem is that the event isn't connecting to the function properly. It's inside of the function which never gets called, so it doesn't ever connect to it.


To fix this, we simply need to move the connection outside of the function like so: (Put this in a LocalScript)

local GUI = script.Parent.Parent

wait(5)
	
for i=0,1,.1 do --Same thing for fading, just requires much less lines. More efficient :P
	GUI.BackgroundTransparency = i
	wait(0.1)
end

GUI.Active = false

Ok, so I believe it should work properly now.


If you have any further problems/questions, please leave a comment below, and I'll see what I can do. Hope I helped :P

####-Dyler3

12 comments

0

Thank you very much!

0

No problem. Would you care to upvote my answer real quick? Someone downvoted it for no reason...anyways, glad I could help :P

0

Thank you

0

Could you help me, please? It still doesn't work, i've tried local script and a normal script. No errors, just does nothing.

0

It does nothing?

0

Nope. Nothing at all.

0

Hmm, try it now. I made it so it clones the frame instead of moving it.

0

Still nothing, could it be to do with my settings?

0

Well first tell me, does the GUI even show on the players screen in the first place?

0

Yes, it does. It just doesn't fade.

0

Message me on Roblox, and we'll work it out there

0

Thanks! Works like a charm now :)

You should always place your connection line outside of the function block, And lines 8-26 can be shortened if a for loop is used.

A For loop?

A for loop has an iterator that is supposed to keep track on how many times the for loop is to run, for Instance.

for iterator = begin, last , increment do -- the begin is where the value must start, the last is where the value must end, and increment is the amount of decrease/increase.

for i = 1, 5, 1 do
	wait(1)
	print("Amount of Seconds remaining "..i)
end

-- > Amount of Seconds remaining 1 , Amount of Seconds remaining 2. Etc.

Final Product

function onPlayerEntered(swag)
	local GUI = script.Parent.Parent
	GUI.Parent = swag:WaitForChild("PlayerGui")


	wait(5)
	for i = .1, 1 ,.1 do
	wait()
		GUI.BackgroundTransparency = i
	end
	GUI.Active = false
end

game.Players.PlayerAdded:connect(onPlayerEntered) 

5 comments

1

Thank you so much!

0

Sorry to bother you again, but it didn't work. Does nothing, no errors though.

0

Oh forgot to ask, is this a localscript?

0

Oh, no it isn't. Should I make it local?

0

Got it working now, thanks anyway dude :)

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