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

Why is this not working?!

Works in studio though :/

Anyways, I'm making an intro type GUI, so when the player joins the game, coreguis are disabled, the RequestQueue loads and stuffs, once that is done, it proceeds to fade out to a neon brick in-front of the camera rotating around a brick. and once the player clicks the screen, it fades in, fades out and the core gui's are enabled and the camera is back to the player.

I'm using a normal script and a module script to do this.

I am fairly new with render stepped and input service, so all help is appreciated. I am also fairly new to scripting, so don't judge me please :D

WORKING EXAMPLE: (In studio) https://gyazo.com/e9b28cad04bc8c7ebb4712bd356db361

MODULE SCRIPT;

local module = {}

local BlurBlock = nil
local BlurBlocks = {}

local function CreateBlurBlock(player, Camera)
	local block = Instance.new('Part', Camera)
	block.Material = Enum.Material.Neon
	block.Transparency = 0.6
	block.Size = Vector3.new(10,10,1)
	block.CanCollide = false
	block.Locked = true
	block:SetNetworkOwner(player)
	BlurBlocks[player] = block
	return block
end

local function StartCam(rs, Camera)
	local possiblePoints = {}
	table.insert(possiblePoints, Vector3.new(0,50,0))
	for _, child in ipairs(game.Workspace:GetChildren()) do
		if child.Name == "Rotate" then
			table.insert(possiblePoints, child.Position)
		end
	end
	local focalPoint = possiblePoints[math.random(#possiblePoints)]
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.Focus = CFrame.new(focalPoint)
	local angle = 0
	rs:BindToRenderStep('Rotate', Enum.RenderPriority.Camera.Value, function()
		local cameraPosition = focalPoint + Vector3.new(50 * math.cos(angle), 20, 50 * math.sin(angle))
		Camera.CoordinateFrame = CFrame.new(cameraPosition, focalPoint)
		angle = angle + math.rad(.25)	
		if BlurBlock then
			BlurBlock.CFrame = Camera.CoordinateFrame + Camera.CoordinateFrame:vectorToWorldSpace(Vector3.new(0,0,-2))
		end
	end)	
end

local function OnSetBlurBlock(block)
	BlurBlock = block
	BlurBlock.LocalTransparencyModifier = 0
end

function module.Stop(Camera, rs)
	rs:UnbindFromRenderStep('Rotate')
	Camera.CameraType = Enum.CameraType.Custom
end

function module.Start(player, Camera, rs)
	if player then
		local block = CreateBlurBlock(player, Camera)
		OnSetBlurBlock(block)
		StartCam(rs, Camera)
	end
end

return module

And the normal script which distributes the GUI and does the functioning

local ContentProvider = game:GetService("ContentProvider")
local rs = game:GetService("RunService")
local Camera = game.Workspace.CurrentCamera
local Events = game.ReplicatedStorage.Events
local Module = require(Events.CallMe)
local UIS = game:GetService("UserInputService")
local clickq = false

local function fadeout(obj)
	local d = obj
	if d then
		repeat
			if d.BackgroundTransparency < 1 then
				d.BackgroundTransparency = d.BackgroundTransparency + 0.1
				wait(.05)
			else
				d.BackgroundTransparency = 1
			end
		until d.BackgroundTransparency == 1
	end
end

local function fadein(obj)
	local d = obj
	if d then
		repeat
			if d.BackgroundTransparency > 0 then
				d.BackgroundTransparency = d.BackgroundTransparency - 0.1
				wait(.05)
			else
				d.BackgroundTransparency = 0
			end
		until d.BackgroundTransparency == 0
	end
end

local function removecontent(gui)
	repeat
		gui.Sound.Volume = gui.Sound.Volume - .05
		wait(.1)
	until gui.Sound.Volume == 0
	gui.Sound:Stop()
	gui.IntFrame:remove()
	gui.StarterFrame:remove()
end

local function turnoff()
	game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
end

local function turnon()
	game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
end

local function endit(gui)
	local Fade = gui.Fade
	fadein(Fade)
	Module.Stop(Camera, rs)
	removecontent(gui)
	fadeout(Fade)
	turnon()
	gui:remove()
end

game.Players.PlayerAdded:connect(function(player)
	turnoff()
	
	local Gui = script.Intro
	local c = Gui:Clone()
	local back = c.StarterFrame
	local Loaf = back.Frame
	local sound = c.Sound
	local int = c.IntFrame
	local Logo = int.Logo
	local Slogan = int.Slogan
	local clicky = int.Clicky
	
	c.Parent = player.PlayerGui
	
	sound:Play()
	
	while (ContentProvider.RequestQueueSize > 0) do
		local cp = ContentProvider.RequestQueueSize
		Loaf.Label.Text = "Queue: "..cp
		wait()
	end
	
	wait(2)
	Loaf:TweenPosition(UDim2.new(0.5, -125, .6, -125), "Out", "Quad", 1, true)
	wait(.1)
	Loaf:TweenPosition(UDim2.new(0.5, -125, -1, -125), "Out", "Quad", 1, true)
	wait(1)
	Module.Start(player, Camera, rs)
	fadeout(back)
	wait()
	Slogan:TweenPosition(UDim2.new(0.5, -200, 0.5, 125), "Out", "Quad", 1, true)
	wait(.2)
	Logo:TweenPosition(UDim2.new(0.5, -125, 0.5, -125), "Out", "Quad", 1, true)
	wait(1)
	clicky:TweenPosition(UDim2.new(0.5, -100, 1, -50), "Out", "Quad", 1, true)
	clickq = true
	UIS.InputBegan:connect(function(Input)
    	if Input.UserInputType == Enum.UserInputType.MouseButton1 and clickq then
       	 endit(c)
   		end
	end)
end)

1 answer

✓ Accepted answer

The reason why it's not working because you aren't waiting for the GUI's. In Studio, this doesn't apply, because the player (i think) loads in after everything else in studio.

Here you have your GUI variables:

local Gui = script.Intro
local c = Gui:Clone()
local back = c.StarterFrame
local Loaf = back.Frame
local sound = c.Sound
local int = c.IntFrame
local Logo = int.Logo
local Slogan = int.Slogan
local clicky = int.Clicky

but in the real server, to not have errors, you should do this:

local Gui = script:WaitForChild("Intro")
local c = Gui:Clone()
local back = c:WaitForChild("StarterFrame")
local Loaf = back:WaitForChild("Frame")
local sound = c.Sound
local int = c:WaitForChild("IntFrame")
local Logo = int:WaitForChild("Logo")
local Slogan = int:WaitForChild("Slogan")
local clicky = int:WaitForChild("Clicky")

I had this problem before, so I don't blame you.

Hope I helped,

PickUpTheBeat1

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