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

My intro gui starts over when a player how to fix?

My Intro Gui restarts everytime a player dies what can i do to make it not do it?

game.StarterGui:SetCoreGuiEnabled("All", false)

local assets = {274693209, 274693209, 274693209}

for i, v in pairs(assets) do
	game:GetService("ContentProvider"):Preload("rbxassetid://" .. v)
end

local music = script.Parent:WaitForChild("Music")
local image = script.Parent:WaitForChild("Frame"):WaitForChild("Logo")
local background = script.Parent:WaitForChild("Frame")
local bg2 = background:WaitForChild("BG")
local bgColor = background.BackgroundColor3

--start doing work
wait(2)

local devs = {"xOmqDiamondxXx"}
local positions = {
	UDim2.new(1.1, 0, 1.1, 0),
	UDim2.new(-0.1, 0, 1.1, 0),
	UDim2.new(-0.1, 0, -0.1, 0),
	UDim2.new(1.1, 0, -0.1, 0),
	UDim2.new(0.5, 0, -0.1, 0),
	UDim2.new(0.5, 0, 1.1, 0),
	UDim2.new(1.1, 0, 0.5, 0),
	UDim2.new(-0.1, 0, 0.5, 0)
}
local activeDevs = {}

function newDev()
	local dev = Instance.new("ImageLabel", script.Parent)
	dev.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username=" .. tostring(devs[math.random(#devs)])
	dev.Position = positions[math.random(#positions)]
	dev.Size = UDim2.new(0, 200, 0, 200)
	dev.Name = "Developer"
	dev.ZIndex = 2
	dev.BorderSizePixel = 0
	dev.BackgroundTransparency = 1
 	local moveX = Instance.new("NumberValue", dev)
	moveX.Name = "MoveX"
	moveX.Value = math.random(5)
	if dev.Position.X.Scale > 0 then
		moveX.Value = moveX.Value * -1
	end
 	local moveY = Instance.new("NumberValue", dev)
	moveY.Name = "MoveY"
	moveY.Value = math.random(5)
	if dev.Position.Y.Scale > 0 then
		moveY.Value = moveY.Value * -1
	end
	local rotate = Instance.new("NumberValue", dev)
	rotate.Name = "Rotate"
	rotate.Value = math.random(-8, 8) * math.random()
end

local flashTime = {0.96, 2.23, 3.61, 4.94, 6.38, 7.71, 9.09}
for i, v in pairs(flashTime) do
	coroutine.wrap(function()
		wait(v + 0.3)
		background.BackgroundColor3 = Color3.new(1, 1, 1)
		image:TweenSizeAndPosition(UDim2.new(0, 330, 0, 250), UDim2.new(0.5, -165, 0.5, -125), "Out", "Quad", 0.1)
		bg2:TweenSizeAndPosition(UDim2.new(0, 350, 0, 270), UDim2.new(0.5, -175, 0.5, -135), "Out", "Quad", 0.1)
		wait(0.12)
		background.BackgroundColor3 = bgColor
		image:TweenSizeAndPosition(UDim2.new(0, 280, 0, 200), UDim2.new(0.5, -140, 0.5, -100), "In", "Quad", 0.1)
		bg2:TweenSizeAndPosition(UDim2.new(0, 300, 0, 220), UDim2.new(0.5, -150, 0.5, -110), "Out", "Quad", 0.1)
	end)()
end

music:Play()

for i = 1, 10 do
	music.Volume = music.Volume + 0.1
	wait(0.1)
end
--nine seconds to animate
for i = 1, 20 do
	newDev()
end
coroutine.wrap(function()
	for _ = 1, 1000 do
		wait()
		for i, v in pairs(script.Parent:GetChildren()) do
			if v.Name == "Developer" and v:FindFirstChild("MoveX") and v:FindFirstChild("MoveY") and v:FindFirstChild("Rotate") then
				v.Position = v.Position + UDim2.new(0, v.MoveX.Value, 0, v.MoveY.Value)
				v.Rotation = v.Rotation + v.Rotate.Value
			end
		end
	end
end)()

wait(9)

coroutine.wrap(function()
	repeat
		wait()
		image.Rotation = image.Rotation + 12
		image.Size = image.Size - UDim2.new(0, 10, 0, 8)
		image.Position = image.Position + UDim2.new(0, 5, 0, 4)
		bg2.Rotation = image.Rotation + 12
		bg2.Size = image.Size - UDim2.new(0, 10, 0, 8)
		bg2.Position = image.Position + UDim2.new(0, 5, 0, 4)
	until image.Size.X.Offset <= 0
	image:Destroy()
	bg2:Destroy()
end)()

coroutine.wrap(function()
	for i = 1, 65 do
		wait()
		for _, v in pairs(script.Parent:GetChildren()) do
			if not v:IsA("LocalScript") and not v:IsA("Sound") then
				v.Transparency = v.Transparency + 1/65
			end
			if v:IsA("ImageLabel") then
				v.ImageTransparency = v.ImageTransparency + 1/65
			end
		end
	end
end)()

for i = 1, 10 do
	music.Volume = music.Volume - 0.1
	wait(0.1)
end

wait(2)

game.StarterGui:SetCoreGuiEnabled("All", true)
script.Parent:Destroy() 

2 comments

0

Edited for code block. Please place your code in a code block in the future.

0

Have the script cloned into PlayerGui through another script on when the player first joins the game.

2 answers

✓ Accepted answer

This is because every time a player dies the guis reset and so this runs again. What you want is only have it when the player joins the server so this would be the function:

game.Player.PlayerAdded:connect(function(player)--define the player
--code
end)

This will make it so that once the player joins it runs, but when they die it doesn't run. So it only runs when the player joins the server. This would be your full script:

game.StarterGui:SetCoreGuiEnabled("All", false)

local assets = {274693209, 274693209, 274693209}

for i, v in pairs(assets) do
    game:GetService("ContentProvider"):Preload("rbxassetid://" .. v)
end

local music = script.Parent:WaitForChild("Music")
local image = script.Parent:WaitForChild("Frame"):WaitForChild("Logo")
local background = script.Parent:WaitForChild("Frame")
local bg2 = background:WaitForChild("BG")
local bgColor = background.BackgroundColor3

--start doing work
game.Players.PlayerAdded:connect(function(player)
wait(2)

local devs = {"xOmqDiamondxXx"}
local positions = {
    UDim2.new(1.1, 0, 1.1, 0),
    UDim2.new(-0.1, 0, 1.1, 0),
    UDim2.new(-0.1, 0, -0.1, 0),
    UDim2.new(1.1, 0, -0.1, 0),
    UDim2.new(0.5, 0, -0.1, 0),
    UDim2.new(0.5, 0, 1.1, 0),
    UDim2.new(1.1, 0, 0.5, 0),
    UDim2.new(-0.1, 0, 0.5, 0)
}
local activeDevs = {}

function newDev()
    local dev = Instance.new("ImageLabel", script.Parent)
    dev.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username=" .. tostring(devs[math.random(#devs)])
    dev.Position = positions[math.random(#positions)]
    dev.Size = UDim2.new(0, 200, 0, 200)
    dev.Name = "Developer"
    dev.ZIndex = 2
    dev.BorderSizePixel = 0
    dev.BackgroundTransparency = 1
    local moveX = Instance.new("NumberValue", dev)
    moveX.Name = "MoveX"
    moveX.Value = math.random(5)
    if dev.Position.X.Scale > 0 then
        moveX.Value = moveX.Value * -1
    end
    local moveY = Instance.new("NumberValue", dev)
    moveY.Name = "MoveY"
    moveY.Value = math.random(5)
    if dev.Position.Y.Scale > 0 then
        moveY.Value = moveY.Value * -1
    end
    local rotate = Instance.new("NumberValue", dev)
    rotate.Name = "Rotate"
    rotate.Value = math.random(-8, 8) * math.random()
end

local flashTime = {0.96, 2.23, 3.61, 4.94, 6.38, 7.71, 9.09}
for i, v in pairs(flashTime) do
    coroutine.wrap(function()
        wait(v + 0.3)
        background.BackgroundColor3 = Color3.new(1, 1, 1)
        image:TweenSizeAndPosition(UDim2.new(0, 330, 0, 250), UDim2.new(0.5, -165, 0.5, -125), "Out", "Quad", 0.1)
        bg2:TweenSizeAndPosition(UDim2.new(0, 350, 0, 270), UDim2.new(0.5, -175, 0.5, -135), "Out", "Quad", 0.1)
        wait(0.12)
        background.BackgroundColor3 = bgColor
        image:TweenSizeAndPosition(UDim2.new(0, 280, 0, 200), UDim2.new(0.5, -140, 0.5, -100), "In", "Quad", 0.1)
        bg2:TweenSizeAndPosition(UDim2.new(0, 300, 0, 220), UDim2.new(0.5, -150, 0.5, -110), "Out", "Quad", 0.1)
    end)()
end

music:Play()

for i = 1, 10 do
    music.Volume = music.Volume + 0.1
    wait(0.1)
end
--nine seconds to animate
for i = 1, 20 do
    newDev()
end
coroutine.wrap(function()
    for _ = 1, 1000 do
        wait()
        for i, v in pairs(script.Parent:GetChildren()) do
            if v.Name == "Developer" and v:FindFirstChild("MoveX") and v:FindFirstChild("MoveY") and v:FindFirstChild("Rotate") then
                v.Position = v.Position + UDim2.new(0, v.MoveX.Value, 0, v.MoveY.Value)
                v.Rotation = v.Rotation + v.Rotate.Value
            end
        end
    end
end)()

wait(9)

coroutine.wrap(function()
    repeat
        wait()
        image.Rotation = image.Rotation + 12
        image.Size = image.Size - UDim2.new(0, 10, 0, 8)
        image.Position = image.Position + UDim2.new(0, 5, 0, 4)
        bg2.Rotation = image.Rotation + 12
        bg2.Size = image.Size - UDim2.new(0, 10, 0, 8)
        bg2.Position = image.Position + UDim2.new(0, 5, 0, 4)
    until image.Size.X.Offset <= 0
    image:Destroy()
    bg2:Destroy()
end)()

coroutine.wrap(function()
    for i = 1, 65 do
        wait()
        for _, v in pairs(script.Parent:GetChildren()) do
            if not v:IsA("LocalScript") and not v:IsA("Sound") then
                v.Transparency = v.Transparency + 1/65
            end
            if v:IsA("ImageLabel") then
                v.ImageTransparency = v.ImageTransparency + 1/65
            end
        end
    end
end)()

for i = 1, 10 do
    music.Volume = music.Volume - 0.1
    wait(0.1)
end

wait(2)

game.StarterGui:SetCoreGuiEnabled("All", true)
script.Parent:Destroy() 
end)

Hope this helps!

1 comment

0

Thank You!

I'm guessing that your issue is that when the player respawns, it plays. Here's a way to fix that issue. We're going to have the game have a value to see if the intro already played.

game.Players.PlayerJoined:connect(function(p)

local Intro = Instance.new("BoolValue")
Intro.Parent = p
Intro.Value = False

Put that in a script in Workspace.

if game.Players.LocalPlayer.Intro.Value == false then
game.Players.LocalPlayer.Intro.Value = true
game.StarterGui:SetCoreGuiEnabled("All", false)

local assets = {274693209, 274693209, 274693209}

for i, v in pairs(assets) do
    game:GetService("ContentProvider"):Preload("rbxassetid://" .. v)
end

local music = script.Parent:WaitForChild("Music")
local image = script.Parent:WaitForChild("Frame"):WaitForChild("Logo")
local background = script.Parent:WaitForChild("Frame")
local bg2 = background:WaitForChild("BG")
local bgColor = background.BackgroundColor3

--start doing work
wait(2)

local devs = {"xOmqDiamondxXx"}
local positions = {
    UDim2.new(1.1, 0, 1.1, 0),
    UDim2.new(-0.1, 0, 1.1, 0),
    UDim2.new(-0.1, 0, -0.1, 0),
    UDim2.new(1.1, 0, -0.1, 0),
    UDim2.new(0.5, 0, -0.1, 0),
    UDim2.new(0.5, 0, 1.1, 0),
    UDim2.new(1.1, 0, 0.5, 0),
    UDim2.new(-0.1, 0, 0.5, 0)
}
local activeDevs = {}

function newDev()
    local dev = Instance.new("ImageLabel", script.Parent)
    dev.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username=" .. tostring(devs[math.random(#devs)])
    dev.Position = positions[math.random(#positions)]
    dev.Size = UDim2.new(0, 200, 0, 200)
    dev.Name = "Developer"
    dev.ZIndex = 2
    dev.BorderSizePixel = 0
    dev.BackgroundTransparency = 1
    local moveX = Instance.new("NumberValue", dev)
    moveX.Name = "MoveX"
    moveX.Value = math.random(5)
    if dev.Position.X.Scale > 0 then
        moveX.Value = moveX.Value * -1
    end
    local moveY = Instance.new("NumberValue", dev)
    moveY.Name = "MoveY"
    moveY.Value = math.random(5)
    if dev.Position.Y.Scale > 0 then
        moveY.Value = moveY.Value * -1
    end
    local rotate = Instance.new("NumberValue", dev)
    rotate.Name = "Rotate"
    rotate.Value = math.random(-8, 8) * math.random()
end

local flashTime = {0.96, 2.23, 3.61, 4.94, 6.38, 7.71, 9.09}
for i, v in pairs(flashTime) do
    coroutine.wrap(function()
        wait(v + 0.3)
        background.BackgroundColor3 = Color3.new(1, 1, 1)
        image:TweenSizeAndPosition(UDim2.new(0, 330, 0, 250), UDim2.new(0.5, -165, 0.5, -125), "Out", "Quad", 0.1)
        bg2:TweenSizeAndPosition(UDim2.new(0, 350, 0, 270), UDim2.new(0.5, -175, 0.5, -135), "Out", "Quad", 0.1)
        wait(0.12)
        background.BackgroundColor3 = bgColor
        image:TweenSizeAndPosition(UDim2.new(0, 280, 0, 200), UDim2.new(0.5, -140, 0.5, -100), "In", "Quad", 0.1)
        bg2:TweenSizeAndPosition(UDim2.new(0, 300, 0, 220), UDim2.new(0.5, -150, 0.5, -110), "Out", "Quad", 0.1)
    end)()
end

music:Play()

for i = 1, 10 do
    music.Volume = music.Volume + 0.1
    wait(0.1)
end
--nine seconds to animate
for i = 1, 20 do
    newDev()
end
coroutine.wrap(function()
    for _ = 1, 1000 do
        wait()
        for i, v in pairs(script.Parent:GetChildren()) do
            if v.Name == "Developer" and v:FindFirstChild("MoveX") and v:FindFirstChild("MoveY") and v:FindFirstChild("Rotate") then
                v.Position = v.Position + UDim2.new(0, v.MoveX.Value, 0, v.MoveY.Value)
                v.Rotation = v.Rotation + v.Rotate.Value
            end
        end
    end
end)()

wait(9)

coroutine.wrap(function()
    repeat
        wait()
        image.Rotation = image.Rotation + 12
        image.Size = image.Size - UDim2.new(0, 10, 0, 8)
        image.Position = image.Position + UDim2.new(0, 5, 0, 4)
        bg2.Rotation = image.Rotation + 12
        bg2.Size = image.Size - UDim2.new(0, 10, 0, 8)
        bg2.Position = image.Position + UDim2.new(0, 5, 0, 4)
    until image.Size.X.Offset <= 0
    image:Destroy()
    bg2:Destroy()
end)()

coroutine.wrap(function()
    for i = 1, 65 do
        wait()
        for _, v in pairs(script.Parent:GetChildren()) do
            if not v:IsA("LocalScript") and not v:IsA("Sound") then
                v.Transparency = v.Transparency + 1/65
            end
            if v:IsA("ImageLabel") then
                v.ImageTransparency = v.ImageTransparency + 1/65
            end
        end
    end
end)()

for i = 1, 10 do
    music.Volume = music.Volume - 0.1
    wait(0.1)
end

wait(2)

game.StarterGui:SetCoreGuiEnabled("All", true)
script.Parent:Destroy() 
end

This is untested and I'm just going off what I remember for my game's intro. There might be issues, but hopefully you get the idea. If you need more help leave a comment.

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