I was making a intro script for my gui, but it doesn't work for some reason. It maybe a common error which i'm too stupid to realize, i putted a print, i tried local and regular scripts but it doesn't work. Why?
game.Players.PlayerAdded:Connect(function(player) print("xd") player.PlayerGui.Intro.IntroMusic:Play() wait(3) script.Parent.TextLabel.Visible = false player.PlayerGui.Intro.Frame.BackgroundTransparency = player.PlayerGui.Intro.Frame.BackgroundTransparency -.1 player.PlayerGui.Intro.Frame.BackgroundTransparency = player.PlayerGui.Intro.Frame.BackgroundTransparency -.1 player.PlayerGui.Intro.Frame.BackgroundTransparency = player.PlayerGui.Intro.Frame.BackgroundTransparency -.1 player.PlayerGui.Intro.Frame.BackgroundTransparency = player.PlayerGui.Intro.Frame.BackgroundTransparency -.1 player.PlayerGui.Intro.Frame.BackgroundTransparency = player.PlayerGui.Intro.Frame.BackgroundTransparency -.1 end)
if your doing this on the server, you cannot access GUI objects inside a player's PlayerGui
. instead use a remote event so the client can make the BackgroundTransparency fade. also use a for loop to make your code shorter and more compact.
--server local remote = game.ReplicatedStorage.RemoteEvent -- maybe this was the remote game.Players.PlayerAdded:Connect(function(player) print("xd") remote:FireClient(player, "fadeGui") -- fire to the client that joined end)
client:
--local script inside the GUI local remote = game.ReplicatedStorage.RemoteEvent local intro = script.Parent.Parent remote.OnClientEvent:Connect(function(fadeGui) if fadeGui == "fadeGui" then intro.IntroMusic:Play() intro.Stopped:Wait() -- wait till the sound stopped playing script.Parent.TextLabel.Visible = false for i = 1,0,-.1 do intro.Frame.BackgroundTransparency = i -- use the value to set the transparency wait() end end end)