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)
local a = game.ReplicatedStorage["Finish Game"] local b = game:GetService('Players').LocalPlayer.PlayerGui local c = game:GetService('Players').LocalPlayer a.OnClientEvent:Connect(function() b.Ending.Enabled = true for i = 1, 4 do b.Ending.Frame.BackgroundTransparency -= .25 b.Ending.Frame.ImageLabel.ImageTransparency -= .25 b.Ending.Frame.ImageLabel.UIStroke.Transparency -= .25 b.Ending.Frame.TextLabel.TextTransparency -= .25 b.Ending.Frame.TextLabel.UIStroke.Transparency -= .25 wait(.1) end wait(10) c:Kick("Thank You For Playing") 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.
local a = game.ReplicatedStorage["Finish Game"] local b = game.Players.LocalPlayer.PlayerGui local c = game.Players.LocalPlayer print("Local Fine") a.OnClientEvent:Connect(function() print("Got Event") b.Ending.Enabled = true for i = 1, 4 do print("Transparency") b.Ending.Frame.BackgroundTransparency -= .25 --maybe try changing + to - b.Ending.Frame.ImageLabel.ImageTransparency -= .25 b.Ending.Frame.ImageLabel.UIStroke.Transparency -= .25 b.Ending.Frame.TextLabel.TextTransparency -= .25 b.Ending.Frame.TextLabel.UIStroke.Transparency -= .25 wait(.1) print("Done") end wait(10) c:Kick("Thank You For Playing") end)
Hope this helps!!
Updated You can get the player by doing something like this.
part.Touched:Connect(function(hit) local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) if player then game.ReplicatedStorage.RemoteEvent:FireClient(player) end end)
I think there is a problem in the for statement, however, I can't find out exactly yet.
local event = game.ReplicatedStorage["Finish Game"] --most likely the remote event local plr = game:GetService('Players').LocalPlayer --the player local playergui = game:GetService('Players').LocalPlayer.PlayerGui --player gui event.OnClientEvent:Connect(function() playergui.Ending.Enabled = true for i = 1, 4 do playergui.Ending.Frame.BackgroundTransparency += .25 playergui.Ending.Frame.ImageLabel.ImageTransparency += .25 playergui.Ending.Frame.ImageLabel.UIStroke.Transparency += .25 playergui.Ending.Frame.TextLabel.TextTransparency += .25 playergui.Ending.Frame.TextLabel.UIStroke.Transparency += .25 task.wait(.1) end --now, instead of kicking through the client, we will kick through the script that sent this remote, as seen below end)
--everything that comes before this event is fired game.ReplicatedStorage["Finish Game"]:FireAllClients() --fires for every player task.wait(10.4) --time that it would usually take for index,player in pairs(game.Players:GetPlayers()) do --loop through every player -- we will only be using player player:Kick("Thank you for playing!") end
tell me if this doesnt work