I am trying to create a map with waypoints. The waypoint system is a problem, its marked with a exclamation mark on the map, but when you get far away from it it just goes off-screen. It was meant to be a minimap, but i changed my mind.
local refreshTime = 1 -- How often [in seconds] will the minipap refresh. For bigger games, this should be a bigger value
local objectRenderTime = 0 -- How long do you want this to wait after putting a object on the GameMap [in seconds]
--script.Parent.GameMap.Visible=not script.Parent.GameMap.Visible
local Player = game.Players.LocalPlayer
local uis = game:GetService('UserInputService')
uis.InputBegan:Connect(function(inp)
if inp.UserInputType == Enum.UserInputType.Keyboard then
if inp.KeyCode == Enum.KeyCode.M then
--print('map')
script.Parent.GameMap.Visible = not script.Parent.GameMap.Visible
if script.Parent.GameMap.Visible==true then
Player.CameraMode=Enum.CameraMode.LockFirstPerson
else
Player.CameraMode=Enum.CameraMode.Classic
end
wait(.1)
end
end
end)
local MapObjects = workspace
local GameMap = script.Parent:WaitForChild("GameMap")
local Arrow = GameMap:WaitForChild("Arrow")
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Camera = Instance.new("Camera")
Camera.FieldOfView = 1
Camera.CameraType = Enum.CameraType.Scriptable
Camera.Parent = game.Workspace
GameMap.CurrentCamera = Camera
local M = game.Players.LocalPlayer:GetMouse()
local Cam = game.Workspace.CurrentCamera
function WorldToScreen(Pos)
local point = Cam.CoordinateFrame:pointToObjectSpace(Pos)
local aspectRatio = M.ViewSizeX / M.ViewSizeY
local hfactor = math.tan(math.rad(Cam.FieldOfView) / 2)
local wfactor = aspectRatio * hfactor
local x = (point.x / point.z) / -wfactor
local y = (point.y / point.z) / hfactor
local Vec2 = Vector2.new(M.ViewSizeX * (0.5 + 0.5 * x), M.ViewSizeY * (0.5 + 0.5 * y))
return UDim2.new(0, Vec2.X, 0, Vec2.Y)
end
spawn(function()
while wait(refreshTime) do
for i, v in pairs(GameMap:GetChildren()) do
if v.Name ~= 'Arrow' and v.Name ~= 'LeadingArrow' then
v:Destroy()
end
end
for i, Object in pairs(MapObjects:GetChildren()) do
pcall(function()
Object:Clone().Parent = GameMap
end)
end
end
end)
spawn(function()
while wait() do
local l = WorldToScreen(workspace.Waypoints.Part.Position)
script.Parent.GameMap.LeadingArrow.Position = l
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
local camCFrame = CFrame.new(HumanoidRootPart.Position + Vector3.new(0, 5000, 0), HumanoidRootPart.Position)
Camera.CFrame = camCFrame
Arrow.Rotation = -HumanoidRootPart.Orientation.Y - 90
end)
it will be uploaded as a free model.