I want to make like a waypoint system for my map to kinda like highlight a spesific part of the map, this is my current script,
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local CAS = game:GetService("ContextActionService")
local DragModule = require(game:GetService("ReplicatedStorage").DraggableObject)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local testPart = workspace.TestPart
local distance = 9000
local minDistance = 1000
local maxDistance = 12000
local zoomSpeed = 500
local Frame = script.Parent.ViewportFrame
local PlayerArrow = Frame.PlayerArrow
local Blip = Frame.Blip
local frameDrag = DragModule.new(script.Parent)
frameDrag:Enable()
local disableScroll = false
local inside = false
local Camera = Instance.new("Camera", game.Workspace)
Camera.CameraType = Enum.CameraType.Scriptable
Frame.CurrentCamera = Camera
Camera.FieldOfView = 1
Frame.MouseEnter:Connect(function()
inside = true
end)
Frame.MouseLeave:Connect(function()
inside = false
end)
for _, Objects in pairs(workspace:GetChildren()) do
if Objects:IsA("BasePart") and Objects ~= workspace.Terrain then
local Clone = Objects:Clone()
Clone.Parent = Frame
end
end
UserInputService.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseWheel and inside then
distance = math.clamp(distance - (input.Position.Z * zoomSpeed), minDistance, maxDistance)
end
end)
RunService.RenderStepped:Connect(function()
local screenPos, onScreen = Camera:WorldToViewportPoint(testPart.Position)
if onScreen then
local relativeX = (screenPos.X - Frame.AbsolutePosition.X) / Frame.AbsoluteSize.X
local relativeY = (screenPos.Y - Frame.AbsolutePosition.Y) / Frame.AbsoluteSize.Y
Blip.Position = UDim2.new(relativeX, 0, relativeY, 0)
Blip.Visible = true
else
Blip.Visible = false
end
Camera.CFrame = CFrame.new(HumanoidRootPart.Position + Vector3.new(0, distance, 0), HumanoidRootPart.Position)
PlayerArrow.Rotation = -HumanoidRootPart.Orientation.Y - 90
disableScroll = inside
end)
CAS:BindAction("DisableScroll",
function()
return disableScroll and Enum.ContextActionResult.Sink or Enum.ContextActionResult.Pass
end, false, Enum.UserInputType.MouseWheel)
i’ve tried a few stuff like using camera:worldtoviewportpoint or camera:worldtoscreenpoint but it just doesn’t work, i searched on youtube and devforum, but i just couldn’t find anything to help me.
Ask me if you need more information and thanks in advance!
edit: the blip variable is the waypoint (just with a different name)