And here we go again. What I'm trying to do is create a loading GUI for the player, and then darken the color for that GUI for 3 seconds. The code is inside of a regular script, which is then inside of a part. This is the whole script, with no sections left out:

function CreateMainGui(player) --ignore this part
	--do stuff
end

function CreateLoadingGui(player)
	print(player)
	local Var = 0
	local MainGui = Instance.new("ScreenGui", player:FindFirstChild("PlayerGui"))
	local MainFrame = Instance.new("Frame", MainGui)
	MainFrame.Size = UDim2.new(0, 906,0, 468)
	local Text = Instance.new("TextLabel", MainFrame)
	Text.Size = UDim2.new(0, 200,0, 50)
	Text.Position = UDim2.new(0, 340,0, 200)
	while Var <= 60 do
		wait(.05)
		Var = Var + 1
		MainFrame.BackroundColor3 = Color3.new(Var, Var, Var)
	end
	wait(5)
	CreateMainGui(player)
end

script.Parent.Touched:connect(function(object)
	local Var = 0
	if object.Parent:FindFirstChild("Humanoid") then
		if object.Parent.Humanoid.Health ~= 0 and Var == 0 then
			object.Parent.Torso.CFrame = CFrame.new(workspace.SPLobby.SPLobbySpawnLocation.Position) --ignore this line
			print(object.Parent)
			CreateLoadingGui(object.Parent:FindFirstChild("PlayerGui")) --this is the problem I'm guessing?
			
			Var = 1
		end
	end
end)

The problem is, whenever I'm trying to specify the pararmetersfor all the other functions as the PlayerGui, it always throws out a nil value. Please HALP!! THX!!!

2 comments

0

this this a server or local script?

0

Look at my desc.