Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My client side GUI won't work, why?

Asked by 9 years ago

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.

0
Is GUI a screengui or a frame? HungryJaffer 1246 — 9y
0
Frame. It's parented inside of a textlabel, though. User#9487 0 — 9y
0
I mean, the script is parented inside of a textlabel. User#9487 0 — 9y

2 answers

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

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

0
Thank you very much! User#9487 0 — 9y
0
No problem. Would you care to upvote my answer real quick? Someone downvoted it for no reason...anyways, glad I could help :P dyler3 1510 — 9y
0
Thank you dyler3 1510 — 9y
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. User#9487 0 — 9y
View all comments (8 more)
0
It does nothing? dyler3 1510 — 9y
0
Nope. Nothing at all. User#9487 0 — 9y
0
Hmm, try it now. I made it so it clones the frame instead of moving it. dyler3 1510 — 9y
0
Still nothing, could it be to do with my settings? User#9487 0 — 9y
0
Well first tell me, does the GUI even show on the players screen in the first place? dyler3 1510 — 9y
0
Yes, it does. It just doesn't fade. User#9487 0 — 9y
0
Message me on Roblox, and we'll work it out there dyler3 1510 — 9y
0
Thanks! Works like a charm now :) User#9487 0 — 9y
Ad
Log in to vote
1
Answered by
woodengop 1134 Moderation Voter
9 years ago

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) 
1
Thank you so much! User#9487 0 — 9y
0
Sorry to bother you again, but it didn't work. Does nothing, no errors though. User#9487 0 — 9y
0
Oh forgot to ask, is this a localscript? woodengop 1134 — 9y
0
Oh, no it isn't. Should I make it local? User#9487 0 — 9y
0
Got it working now, thanks anyway dude :) User#9487 0 — 9y

Answer this question