Hey there! so, i made a minimap system and ill explain how it works here:
- Script runs
- I loop through the map
- I add map items to the viewport frame
- Every second, i remove everything from the Viewport frame and i readd it so it updates
Now the problem here is that if a “Special Part” appears i put an arrow near that and that arrow will be clickable but i remove that every “RenderStepped” so it doesn’t function.
So, just don’t remove it? I tried that but it just creates a bunch of arrows since i want it to update
Now my first thought was to create the arrow once, add the name to a table (before that ill make a random name for every one of them to identify them) but i can’t make it work.
heres my code:
RunService.RenderStepped:Connect(function()
for _, v in pairs(Frame:GetChildren()) do
if v:FindFirstChild("UIDefault") then continue end
v:Destroy()
end
for i,Elements in pairs(__MAP:GetChildren()) do
local Cloning = Elements:Clone()
Cloning.Parent = Frame
if Cloning.Name == "Pad" and not table.find(created,Cloning) then
table.insert(created,Cloning)
local scale = pointToViewport(Cam,Cloning.Position) --Just a function to know where to put the Arrow, not important in this situation
local charCursor = Frame.Parent:WaitForChild("TPArrow"):Clone()
charCursor.Parent = Frame
charCursor.Object.Value = Elements
charCursor.Visible = true
charCursor.Position = UDim2.new(scale.X, 0, scale.Y, 0)
charCursor.MouseButton1Click:Connect(function()
print("clicked")
Character.PrimaryPart.CFrame = charCursor.Object.Value.CFrame
end)
elseif table.find(created,Cloning) then
for _, v in pairs(Frame:GetChildren()) do
if v:FindFirstChild("Object") and v.Object.Value == Elements then
print("e")
local scale = pointToViewport(Cam,Cloning.Position)
v.Position = UDim2.new(scale.X, 0, scale.Y, 0)
end
end
end
end
Cam.CFrame = CFrame.new(HumanoidRootPart.Position + Vector3.new(0,4000,0), HumanoidRootPart.Position)
PlayerArrow.Rotation = -HumanoidRootPart.Orientation.Y + 70
--PlayerArrow.Rotation = -HumanoidRootPart.Orientation.Y - 90
end)
Also, for anyone wondering, it does not print “e” nor print anything past the "elseif table.find"
Thanks!!