Im making a game where I want the credits to roll upon a players death, but I cant figure out how to make it happen when they die.
local TEXT = { --what to use for credit text; multiple line block formatting shown. "Created by Gaming_CharlesYT"; --use semicolons or commas to separate text blocks [[created with; Copy And Paste Button, Free time, lost hope, my final 5 braincells, Pain Causers:; "my horrible computer always lagging"; "accidentally pasting things in the wrong places" } local PADDING = 60 { --pixels between snippets FADE_TIME = 1 --time it takes for the black to fade in WAIT_TIME = 0 --time it takes after the black fades in for text to start moving SPEED = 40 --pixels/second of text BACKGROUND_COLOR = Color3.new(0, 0, 0) --self-explanatory TEXT_COLOR = Color3.new(1, 1, 1) --self-explanatory BLOCK_MENU_BAR = true --blocks the transparent menu bar at the top of the screen ALLOW_MULTIPLE = false --allow credits to roll, even if they already are (true causes weird graphics) local module = {} --initialize module table --creates a text label and resizes it according to its TextBounds local function CreateTextLabel(text, parent) local label = Instance.new("TextLabel", parent) label.Text = text label.Font = Enum.Font.ArialBold label.FontSize = Enum.FontSize.Size24 label.ZIndex = 10 label.BackgroundTransparency = 1 label.TextColor3 = TEXT_COLOR local textBounds = label.TextBounds label.Size = UDim2.new(0, textBounds.X, 0, textBounds.Y) return label end --fade in background, roll credits local function RollCredits(textArray, screenGui, fadeInTime, waitTime, speed) --create background frame local background = Instance.new("Frame", screenGui) background.Name = "__Credits__" background.ZIndex = 10 background.BackgroundColor3 = BACKGROUND_COLOR background.Size = UDim2.new(1, 0, 1, 0) if BLOCK_MENU_BAR then --make slightly bigger and higher background.Size = UDim2.new(1, 0, 1, 35) background.Position = UDim2.new(0, 0, 0, -35) end background.BackgroundTransparency = 1 background.ClipsDescendants = true --make 0x0 frame for holding all text objects (for easy movement) local frame = Instance.new("Frame", background) frame.BackgroundTransparency = 1 frame.Position = UDim2.new(0.5, 0, 1, 0) local currentY = 0 --keep track of the Y position of the next TextLabel for _, text in pairs(textArray) do local label = CreateTextLabel(text, frame) label.Position = UDim2.new(0, -label.AbsoluteSize.X/2, 0, currentY) --center it and position it currentY = currentY + label.AbsoluteSize.Y + PADDING --move currentY to the bottom of the current TextLabel, and add some padding end local t = 0 --t is time elapsed local a --increases 0-1 while true do t = t + wait() --add delta time to t to keep track of total elapsed a = t/fadeInTime --scale it from 0-1 if a > 1 then break end --reached final time background.BackgroundTransparency = 1-a --move from 1-->0 end background.BackgroundTransparency = 0--finish the loop wait(waitTime) repeat frame.Position = frame.Position + UDim2.new(0, 0, 0, -speed*wait()) --move upwards by speed, scaled to the delta time until frame.AbsolutePosition.Y < -currentY --just so we don't have a constant loop end module.Roll = function(screenGui) --function in module --check for argument & multiple credits if not screenGui then error("Credits.Roll requires a ScreenGui as a parameter") end if screenGui:FindFirstChild("__Credits__") then warn((ALLOW_MULTIPLE and "" or "Did not roll credits because ") .. "ScreenGui \"" .. screenGui.Name .. "\" already contains a credits reel") if not ALLOW_MULTIPLE then return end end coroutine.wrap(function() --don't interupt other things RollCredits(TEXT, screenGui, FADE_TIME, WAIT_TIME, SPEED) --actually roll the credits end)() end return module
That's my current script above, any ideas on how to make it work?