what this script is supposed to do is that when the RemoteEvent is fired, the player who fired the scripts GUI (aka playergui) will change the transparency for the GUI by taking away -.25 for every GUI object listed in the script, once that repeated 4 times, the script will wait 10 seconds before kicking the player who fired it. but the script doesn't work, it doesn't change the gui's transparency or anything at all, if anyone could find a solution that would be great
Script (LocalScript)
01 | local a = game.ReplicatedStorage [ "Finish Game" ] |
02 | local b = game:GetService( 'Players' ).LocalPlayer.PlayerGui |
03 | local c = game:GetService( 'Players' ).LocalPlayer |
04 |
05 |
06 | a.OnClientEvent:Connect( function () |
07 | b.Ending.Enabled = true |
08 | for i = 1 , 4 do |
09 | b.Ending.Frame.BackgroundTransparency - = . 25 |
10 | b.Ending.Frame.ImageLabel.ImageTransparency - = . 25 |
11 | b.Ending.Frame.ImageLabel.UIStroke.Transparency - = . 25 |
12 | b.Ending.Frame.TextLabel.TextTransparency - = . 25 |
13 | b.Ending.Frame.TextLabel.UIStroke.Transparency - = . 25 |
14 | wait(. 1 ) |
15 | end |
16 |
17 | wait( 10 ) |
18 | c:Kick( "Thank You For Playing" ) |
19 | end ) |
The only thing I can see that might be the problem is that you used - instead of + for the transparency part.
I don't think that would cause the script to not work though So I fixed a few things. Like the local player part to :GetService
I also added prints to try to narrow in on the problem. Let me know what prints
are not being printed to narrow in on the issue.
01 | local a = game.ReplicatedStorage [ "Finish Game" ] |
02 | local b = game.Players.LocalPlayer.PlayerGui |
03 | local c = game.Players.LocalPlayer |
04 | print ( "Local Fine" ) |
05 |
06 | a.OnClientEvent:Connect( function () |
07 | print ( "Got Event" ) |
08 | b.Ending.Enabled = true |
09 | for i = 1 , 4 do |
10 | print ( "Transparency" ) |
11 | b.Ending.Frame.BackgroundTransparency - = . 25 --maybe try changing + to - |
12 | b.Ending.Frame.ImageLabel.ImageTransparency - = . 25 |
13 | b.Ending.Frame.ImageLabel.UIStroke.Transparency - = . 25 |
14 | b.Ending.Frame.TextLabel.TextTransparency - = . 25 |
15 | b.Ending.Frame.TextLabel.UIStroke.Transparency - = . 25 |
Hope this helps!!
Updated You can get the player by doing something like this.
1 | part.Touched:Connect( function (hit) |
2 | local player = game:GetService( "Players" ):GetPlayerFromCharacter(hit.Parent) |
3 | if player then |
4 | game.ReplicatedStorage.RemoteEvent:FireClient(player) |
5 |
6 | end |
7 | end ) |
I think there is a problem in the for statement, however, I can't find out exactly yet.
01 | local event = game.ReplicatedStorage [ "Finish Game" ] --most likely the remote event |
02 | local plr = game:GetService( 'Players' ).LocalPlayer --the player |
03 | local playergui = game:GetService( 'Players' ).LocalPlayer.PlayerGui --player gui |
04 | event.OnClientEvent:Connect( function () |
05 | playergui.Ending.Enabled = true |
06 | for i = 1 , 4 do |
07 | playergui.Ending.Frame.BackgroundTransparency + = . 25 |
08 | playergui.Ending.Frame.ImageLabel.ImageTransparency + = . 25 |
09 | playergui.Ending.Frame.ImageLabel.UIStroke.Transparency + = . 25 |
10 | playergui.Ending.Frame.TextLabel.TextTransparency + = . 25 |
11 | playergui.Ending.Frame.TextLabel.UIStroke.Transparency + = . 25 |
12 | task.wait(. 1 ) |
13 | end |
14 |
15 | --now, instead of kicking through the client, we will kick through the script that sent this remote, as seen below |
16 | end ) |
1 | --everything that comes before this event is fired |
2 | game.ReplicatedStorage [ "Finish Game" ] :FireAllClients() --fires for every player |
3 | task.wait( 10.4 ) --time that it would usually take |
4 | for index,player in pairs (game.Players:GetPlayers()) do --loop through every player |
5 | -- we will only be using player |
6 | player:Kick( "Thank you for playing!" ) |
7 | end |
tell me if this doesnt work