I want to make cursor move while scriptable camera type is enabled
2. What is the issue? Include screenshots / videos if possible!
it’s not moving
local SelectedTroops = {}
local cam = game.Workspace.CurrentCamera
local UIS = game:GetService("UserInputService")
local RS = game:GetService("RunService")
local Mouse = game.Players.LocalPlayer:GetMouse()
local Soldiers = game.Workspace.Game.Units
local Mode = "Selecting"
local Modes = {["Z"]="Selecting",["X"]="Building",["C"]="Nothing"}
local function IgnoreTouchedParts (tbl,plt)
local newTbl = {}
for i,v in pairs(tbl) do
if v.Parent.Parent == Soldiers then
table.insert(newTbl,v)
end
end
return newTbl
end
local function GetTouchingParts (obj,plt)
local connection = obj.Touched:Connect(function() end);
local parts = obj:GetTouchingParts()
connection:Disconnect()
local parts = IgnoreTouchedParts(parts,plt)
return parts
end
local function CreatePlate ()
local plate = Instance.new("Part")
plate.Anchored = true
plate.CanCollide = false
plate.Transparency = 0.5
plate.Parent = game.Workspace
plate.Size = Vector3.new(0,0,0)
plate.BrickColor = BrickColor.new("Lime green")
plate.TopSurface = Enum.SurfaceType.Smooth
return plate
end
local function Select (i,plate)
local SP = plate:Clone()
SP.Size = plate.Size + Vector3.new(0,50,0)
SP.Transparency = 1
SP.Parent = game.Workspace
plate.Transparency = 1
local Parts = GetTouchingParts(SP)
SP:Destroy()
plate:Destroy()
SelectedTroops = Parts
print(SelectedTroops)
return true
end
local function Resize (plate,sx,sz,x,z,y)
plate.Size = Vector3.new(sx,0.1,sz)
plate.Position = Vector3.new(x,y,z)
end
local function SelectMode (k)
if k == Enum.KeyCode.Z then
Mode = Modes["Z"]
elseif k == Enum.KeyCode.X then
Mode = Modes["X"]
elseif k == Enum.KeyCode.C then
Mode = Modes["C"]
end
end
UIS.InputBegan:Connect(function(i,isChatting)
if isChatting == false then
--- --- --- --- --- --- ---
local k = i.KeyCode
local t = i.UserInputType
SelectMode(k)
--- --- --- --- --- --- ---
if Mode == "Selecting" then
if t == Enum.UserInputType.MouseButton1 then
local s = Mouse.Hit.Position
local e = Mouse.Hit.Position
local IsEnded = false
local plate = CreatePlate()
UIS.InputEnded:Connect(function(i)
if IsEnded == false then
local k = i.KeyCode
local t = i.UserInputType
if t == Enum.UserInputType.MouseButton1 then
IsEnded = Select(i,plate)
end
end
end)
while wait() and IsEnded == false do
e = Mouse.Hit.Position
local x,z = (s.X+e.X)/2,(s.Z+e.Z)/2
local xs,zs = math.abs(s.X-e.X),math.abs(s.Z-e.Z)
Resize(plate,xs,zs,x,z,s.Y)
end
elseif t == Enum.UserInputType.MouseButton2 then
cam.CameraType = Enum.CameraType.Scriptable
local num = #SelectedTroops
local s = Mouse.Hit.Position
local e = Mouse.Hit.Position
local IsEnded = false
local plate = CreatePlate()
plate.BrickColor = BrickColor.Red()
UIS.InputEnded:Connect(function(i)
if IsEnded == false then
local k = i.KeyCode
local t = i.UserInputType
if t == Enum.UserInputType.MouseButton2 then
cam.CameraType = Enum.CameraType.Custom
plate:Destroy()
end
end
end)
while wait() and IsEnded == false do
e = Mouse.Hit.Position
local x,z = (s.X+e.X)/2,(s.Z+e.Z)/2
local xs,zs = math.abs(s.X-e.X),math.abs(s.Z-e.Z)
Resize(plate,xs,zs,x,z,s.Y)
end
end
elseif Mode == "Building" then
if t == Enum.UserInputType.MouseButton1 then
--place something
end
end
end
end)