Camera wont move in every game

not sure if this is the right category but,

let me run down what happened just before i lost control of the camera (can rotate it but WASD does nothing)

i was making a plugin where i was storing temporary instances inside the Camera instance (as recommended by someone else), i did a typo and one of the temporary instances (a part with a selectionbox within it) didnt appear and the viewport froze, this is when i realise i cant control the camera anymore

at first i thought if i fixed that typo the camera would be fixed too, it didnt

i deleted the camera instance and and the plugin but nothing happened
tried going to other game but the camera is broken there too
even reinstalling studio does nothing

heres the plugin code

---------------------------------------------------------------------------------------------------------------------------------------
assert(plugin, "This script must be run as a plugin!")

local toolbar = plugin:CreateToolbar("Bezier Rails")
local pluginButton = toolbar:CreateButton(
	"Bezier Tracks", --Text that will appear below button
	"Create smooth tracks using bezier curves", --Text that will appear if you hover your mouse on button
	"http://www.roblox.com/asset/?id=71988552055771") --Button icon

local info = DockWidgetPluginGuiInfo.new(
	Enum.InitialDockState.Float, --From what side gui appears
	false, --Widget will be initially enabled
	false, --Don't overdrive previouse enabled state
	500, --default weight
	300 --default height
)

local widget = plugin:CreateDockWidgetPluginGui(
	"Plugin", --A unique and consistent identifier used to storing the widget’s dock state and other internal details
	info --dock widget info
)

widget.Title = "Bezier Rails!" --Giving title to our widget gui
script.MainFrame.Parent = widget
----------------------------------------------------------------------------------------------------------
local objects = script.objects
local module = require(script.Bezier)
----------------------------------------------------------------------------------------------------------
local points_table = {}
local ghosts_table = {}
local rails_table = {}
-----------------------------------------------------------------------------------------------------------
local vel_start_button = objects.velocity_start.Value
local vel_end_button = objects.velocity_end.Value
local curve_start_button = objects.curve_start.Value
local curve_end_button = objects.curve_end.Value
-----------------------------------------------------------------------------------------------------------
--default values
local rail_lenght :number = 1 --in studs
local bank_angle :number= 0 --in degrees
local num_points :number= 20
local vel_start :number= 15
local vel_end :number= 15
--test stuff
objects.curve_start.model.Value = workspace.Rails1
objects.curve_end.model.Value = workspace.Rails
workspace.P1.CFrame = workspace.Rails1.PrimaryPart.CFrame + workspace.Rails1.PrimaryPart.CFrame.LookVector * 1.5
workspace.P4.CFrame = workspace.Rails.PrimaryPart.CFrame + workspace.Rails.PrimaryPart.CFrame.LookVector * 1.5
-----------------------------------------------------------------------------------------------------------
function floatingPointErrorCorrection(number :number)
	
	local corrected = string.format("%.4f", number) --precision up to 4 decimal places
	corrected = corrected:gsub("%.?0+$", "") --remove the dot and trailing zeroes
	return tonumber(corrected)
	
end

function partCreation(size :Vector3, tables, colour :BrickColor, name :string, folder :Folder)
	
	local part = Instance.new("Part", folder)
	
	part.Archivable = false
	part.CanQuery = false
	part.Name = name
	part.Size = size
	part.BrickColor = colour
	part.CanCollide = false
	part.Anchored = true
	table.insert(tables, part)
	
	return part
	
end

function railCreation(template :Model, folder :Folder)
	local rail_clone = template:Clone()
	rail_clone.Parent = folder
	table.insert(rails_table, rail_clone)
end

function folderCreation(name :string)
	
	local folder = Instance.new("Folder")
	
	folder.Archivable = false
	folder.Name = name
	folder.Parent = game:GetService("Workspace").Camera
	
	return folder
	
end

function curveCreation(p1 :Part, p4 :Part)
	
	local orientation, bounding_box_size = objects.curve_start.model.Value:GetBoundingBox()
	
	if vel_start_button.Text ~= nil and tonumber(vel_start_button.Text) then
		
		vel_start = tonumber(vel_start_button.Text)
		
	end
	if vel_end_button.Text ~= nil and tonumber(vel_end_button.Text) then
		
		vel_end = tonumber(vel_end_button.Text)
		
	end

	local p2 = p1.CFrame + p1.CFrame.LookVector * vel_start
	local p3 = p4.CFrame + p4.CFrame.LookVector * vel_end
	
	
	local bezier = module.new(p1, p2.Position, p3.Position, p4)
	rail_lenght = floatingPointErrorCorrection(bounding_box_size.Z)
	num_points = math.floor(bezier.Length / rail_lenght) + 1
	
	print(rail_lenght, num_points)
	return num_points, bezier
	
end

function curvePreview()
	--testing curve preview delete onCreateCurve stuff when done
	widget.Enabled = not widget.Enabled
	
	local num_points, bezier = curveCreation(workspace.P1, workspace.P4)
	local orientation, bounding_box_size = objects.curve_start.model.Value:GetBoundingBox()
	local ghosts_folder = folderCreation("GHOST_FOLDER")
	local point_folder = folderCreation("POINT_FOLDER")
	
	for i = 1, num_points do

		partCreation(Vector3.new(.5, .5, .5), points_table, BrickColor.new("Really red"), "POINT", point_folder)

	end
	
	for i = 1, #points_table do

		local t = (i - 1) / (#points_table - 1)
		-- calculates the position and derivative of the Bezier Curve at t
		local position = bezier:CalculatePositionRelativeToLength(t)
		local derivative = bezier:CalculateDerivativeRelativeToLength(t)
		-- sets the position and orientation of the point based on the 
		-- position and derivative of the Bezier Curve
		points_table[i].CFrame = CFrame.new(position, position + derivative)

	end
	
	for i = 1, num_points - 1 do
		
		local ghost_part :Part = partCreation(bounding_box_size, ghosts_table, BrickColor.new("Black"), "GHOST", ghosts_folder)
		local selection_box = Instance.new("SelectionBox")
		
		ghost_part.Transparency	 = 1
		selection_box.Parent = ghost_part
		selection_box.Adornee = ghost_part
		
		local ghost :Part= ghosts_table[i]
		local p1, p2 = points_table[i].Position, points_table[i + 1].Position

		ghost:PivotTo(CFrame.new(0.5 * (p1 + p2), p2) * CFrame.fromAxisAngle(Vector3.new(0, 0, 1),math.rad(-1 * math.abs(2*bank_angle/(num_points - 1)*(i-1-(num_points - 1)/2)) + bank_angle)))
		
	end
	
end

function onCreateCurve()

	local num_points, bezier = curveCreation(workspace.P1, workspace.P4)
	local point_folder = folderCreation("POINT_FOLDER")
	
	for i = 1, num_points do

		partCreation(Vector3.new(.5, .5, .5), points_table, BrickColor.new("Really red"), "POINT", point_folder)

	end

	for i = 1, num_points - 1 do

		railCreation(objects.curve_start.model.Value, point_folder)

	end

	for i = 1, #points_table do

		local t = (i - 1) / (#points_table - 1)
		-- calculates the position and derivative of the Bezier Curve at t
		local position = bezier:CalculatePositionRelativeToLength(t)
		local derivative = bezier:CalculateDerivativeRelativeToLength(t)
		-- sets the position and orientation of the point based on the 
		-- position and derivative of the Bezier Curve
		points_table[i].CFrame = CFrame.new(position, position + derivative)

	end

	for i = 1, #rails_table do

		--rails_table[1].PrimaryPart.BrickColor = BrickColor.new("b")

		local rail :Model= rails_table[i]
		local p1, p2 = points_table[i].Position, points_table[i + 1].Position

		rail:PivotTo(CFrame.new(0.5 * (p1 + p2), p2) * CFrame.fromAxisAngle(Vector3.new(0, 0, 1),math.rad(-1 * math.abs(2*bank_angle/#rails_table*(i-1-#rails_table/2)) + bank_angle)))

		--print((points[1].Position - points[2].Position))
		--print(workspace.P1.Rotation.Z, workspace.P4.Rotation.Z)
		--rail:PivotTo(CFrame.new(0.5 * (p1 + p2), p2)
		--* CFrame.fromAxisAngle(
		--	Vector3.new(0, 0, 1), 
		--	math.rad(
		--		- math.abs( 
		--			-1 * math.abs(2*desired_angle/#rails*(i-1-#rails/2)) + desired_angle))))

	end
	
end

function onClick()
	
	widget.Enabled = not widget.Enabled
	
end

function onClose()
	
	if widget.Enabled == false then
		
		if workspace.Camera:FindFirstChild("POINT_FOLDER") then
			workspace.Camera.POINT_FOLDER:Destroy()
		end
		if workspace.Camera:FindFirstChild("GHOST_FOLDER") then
			workspace.Camera.GHOST_FOLDER:Destroy()
		end
		
		table.clear(points_table)
		table.clear(rails_table)
		table.clear(ghosts_table)
		print("Widget closed") 
		
	end
	
end

pluginButton.Click:Connect(curvePreview)

widget:GetPropertyChangedSignal("Enabled"):Connect(onClose)

PLEASE if you have anything to solve this issue please tell me, this is quite urgent

FIXED! somehow that bug caused the studio camera speed to be infinite setting it back to a normal value gave control back

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.