hello, i made a minimap using a viewportframe but it isn’t making the objects that are obscuring the camera go invisible.
local viewPort = script.Parent:WaitForChild("ViewportFrame")
local charPart = viewPort:WaitForChild("Player")
local roads = workspace:WaitForChild("Roads")
local buildings = workspace:WaitForChild("Buildings")
local hotkey = Enum.KeyCode.M
local UIS = game:GetService("UserInputService")
local open = false
local frame = script.Parent.Parent
UIS.InputBegan:Connect(function(key, gp)
if key.KeyCode == hotkey then
if UIS:GetFocusedTextBox() == nil then
if open == false then
open = true
frame.Visible = open
elseif open == true then
open = false
frame.Visible = open
end
end
end
end)
roads:Clone().Parent = viewPort
buildings:Clone().Parent = viewPort
local camera = Instance.new("Camera", workspace)
camera.CameraType = "Scriptable"
local height = 300
local player = game.Players.LocalPlayer
repeat wait() until player.Character
viewPort.CurrentCamera = camera
game:GetService("RunService").RenderStepped:Connect(function ()
local position1 = player.Character.HumanoidRootPart.Position
camera.CFrame = CFrame.new(Vector3.new(position1.X,height,position1.Z), position1)
charPart.CFrame = player.Character.HumanoidRootPart.CFrame
end)
--raycasting
local roads = workspace:WaitForChild("Roads")
local buildings = workspace:WaitForChild("Buildings")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local head = character:FindFirstChild("Head")
local ray = Ray.new(head.Position, Vector3.new(0,50,0))
local Camera = game.Workspace.Camera
while wait(1) do
local ray = Ray.new(head.Position, Vector3.new(0,50,0))
local whiteList = {roads, buildings}
local hit, position = game.Workspace:FindPartOnRayWithWhitelist(ray, whiteList)
if hit then
viewCamera = viewPort.CurrentCamera
local castPoints = {Vector3.new(0, 10, 0), Vector3.new(0, 15, 0)}
local ignoreList = {}
viewCamera:GetPartsObscuringTarget(castPoints, ignoreList)
print('ray hit a part!')
else
print('no part found')
end
end
I get the notification that the part is being hit by the ray bit i don’t know how to fix this.