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

Intro script in a gui malfunctioning, what should i do?

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) 

2 comments

0

use a for loop

0

Use local scripts for screen guis.

1 answer

✓ Accepted answer

##server

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)

2 comments

0

Ill try that.

0

Works, i just had to tweak it a bit. It also helped me learn a bit about remote events.

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