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

(string expected, got nil) Help! If i add the ring desc the script breaks! what to do?

--// VARIABLES \\--

local cam = workspace.CurrentCamera
local soundEffect = workspace:WaitForChild("SoundEffects")
local Cpart = workspace:WaitForChild("CamPart")
local Cfolder = workspace:WaitForChild("Cams")
local Next = script.Parent:WaitForChild("Next")
local Back = script.Parent:WaitForChild("Back")
local Play = script.Parent:WaitForChild("Play")
local ts = game:GetService("TeleportService")
local w = soundEffect:WaitForChild("woosh")
local p = game.Players.LocalPlayer
local pg = p:WaitForChild("PlayerGui")
local text = script.Parent:WaitForChild("World")
local info = script.Parent:WaitForChild("Info")
local n = soundEffect:WaitForChild("no")

--// TABLES \\--

local cams = {} --Cams , don't add anything into it
local worlds = {"Layer 1 The Surface","Layer 2 Underwater","Layer 3 Deeps","Layer  4 Bottom Of The Trench","FINAL STRECH"}--Ring Names
local desc = {
	"The Surface:  A Rocky Surface Of Tall Towers of obstacles no one used to live on it but you came for adventure good luck",
	"WIP_UnderWater_Layer",
	"WIP_Deeps_Layer",
	"WIP_Bottom Of The Trench_Layer"
}
local ids = {5022168962,"ring2 id","ring3 id","ring 4 id","the final strech id"} --Places ids
local curCam = 1 --Do not touch at this
local max = 0 --Do not touch at this

local rs = game:GetService("RunService")

--// CHANGE PARTS TRANSPARENCY \\--

for i,v in pairs(Cfolder:GetChildren())do
	v.Transparency = 1
	table.insert(cams,i,v)
	max = max + 1
end
Cpart.Transparency = 1

--// CHANGE CAM TYPE/POSITION \\--
repeat wait() cam.CameraType = Enum.CameraType.Scriptable until cam.CameraType == Enum.CameraType.Scriptable
Cpart.CFrame = cams[curCam].CFrame
text.Text = worlds[curCam]
info.Text = desc[curCam]

--// LOOP \\--
spawn(function()
    rs.RenderStepped:Connect(function()
	cam.CFrame = Cpart.CFrame
    end)
end)

--// FUNCTIONS \\--

--Change cam
local function changeCam(pos)
local ts = game:GetService("TweenService")
local m = Cpart
local p = pos

local info = TweenInfo.new(5,Enum.EasingStyle.Quart,Enum.EasingDirection.Out)
local goal = {Position = p.Position;Orientation = p.Orientation}

local t = ts:Create(m,info,goal)
t:play()
w:Play()
end

--Next cam
local function nextCam()
	nextCam = cams[curCam+1]
	curCam = curCam + 1
    local indexCam = cams[nextCam]
end

--Mouse on gui
local function mouseUp(gui)
	gui:TweenSize(
	UDim2.new(0.169, 0,0.088, 0),
	Enum.EasingDirection.Out,
	Enum.EasingStyle.Quad,
	0.25
	)
end

--Mouse quit gui
local function mouseDown(gui)
	gui:TweenSize(
	UDim2.new(0.145, 0,0.076, 0),
	Enum.EasingDirection.Out,
	Enum.EasingStyle.Quad,
	0.25
	)
end


--Teleporting
local function teleport(plr)
	if curCam == 1 then
    ts:Teleport(ids[curCam],plr)
	elseif curCam == 2 then                 
	ts:Teleport(ids[curCam],plr)
	elseif curCam == 3 then                 
		ts:Teleport(ids[curCam],plr) 
	elseif curCam == 4 then                 
		ts:Teleport(ids[curCam],plr)
	elseif curCam == 5 then                 
		ts:Teleport(ids[curCam],plr)
	end
end

--// EVENTS \\--
Next.MouseButton1Click:Connect(function()
	if curCam ~= max then
	  curCam = curCam + 1
      local indexCam = cams[curCam]
      changeCam(indexCam)
		text.Text = worlds[curCam]
		info.Text = desc[curCam]
	else
	n:Play()
    end
end)

Back.MouseButton1Click:Connect(function()
	if curCam ~= 1 then	
	  curCam = curCam - 1
      local indexCam = cams[curCam]
      changeCam(indexCam)
		text.Text = worlds[curCam]
		info.Text = desc[curCam]
	else
	n:Play()
    end
end)

Back.MouseEnter:Connect(function()
	mouseUp(Back)
end)
Back.MouseLeave:Connect(function()
	mouseDown(Back)
end)
Next.MouseEnter:Connect(function()
	mouseUp(Next)
end)
Next.MouseLeave:Connect(function()
	mouseDown(Next)
end)

--// PLAY BUTTON \\--

Play.MouseButton1Click:Connect(function()
	teleport(p)
	script.Parent:WaitForChild("Teleporting"):TweenPosition(	
	UDim2.new(0,0,0,0),
	Enum.EasingDirection.In,
	Enum.EasingStyle.Quad,
	0.25)
	script.Disabled = true
	pg:SetTopbarTransparency(0)
end)

1 answer

You need to use tweenservice, which you did not use. Hope that solves the problem.(Update) To really get a players camera, you need to use a localscript, else there is no camera on a server except when you playtest as a server.

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