Ok now I have a REAL code with my trial, error and notes to show to you guys:
wait(2)
--game.Workspace.CurrentCamera:WorldToScreenPoint(game.Workspace.Part.Position)
--game.Workspace.CurrentCamera:WorldToScreenPoint(game.Workspace.Part)
--game.Workspace.CurrentCamera:WorldToScreenPoint(game.Workspace.Part.Position-game.Workspace.Part2.Position)
--game.Workspace.CurrentCamera:WorldToScreenPoint(game.Workspace.Part.Position)
--[[while wait() do
position, onscreen = game.Workspace.CurrentCamera:WorldToScreenPoint(game.Workspace.Part.Position)--You can change onscreen to what ever you want as long as you change it everywhere else aswell
print(position.x,position.y,"It is ".. tostring(onscreen) .." that the part is on screen") -- 1300,1200, It is true that the part is on screen
end]]
--[[while wait() do
position, onscreen = game.Workspace.CurrentCamera:WorldToScreenPoint(game.Workspace.Part.Position)--You can change onscreen to what ever you want as long as you change it everywhere else aswell
print(position.x,position.y,"It is ".. tostring(onscreen) .." that the part is on screen") -- 1300,1200, It is true that the part is on screen
if onscreen==false then--I tested it out and these types of if statements work aswell
print("t1")
elseif onscreen==true then
print("t2")
end
end]]
--Now time to test out WorldToViewportPoint
--[[while wait() do
position, onscreen = game.Workspace.CurrentCamera:WorldToViewportPoint(game.Workspace.Part.Position)
print(position.x,position.y,"It is ".. tostring(onscreen) .." that the part is on screen") -- 1300,1200, It is true that the part is on screen
if onscreen==false then--I tested it out and these types of if statements work aswell
print("t1")
--script.Parent.ScreenGui.Frame.Position = UDim2.new(0,position.x,0,position.y)--This goes to the opposite point
script.Parent.ScreenGui.Frame.Position = UDim2.new(0,-position.x,0,-position.y)
elseif onscreen==true then
print("t2")
end
end]]
--Before I go back to continuing WorldViewportPoitn im gonna try the same thing, but as WorldScreenPoint
while wait() do--This is actually more accurate cause it says on where the pos is, so just add boundaries
position, onscreen = game.Workspace.CurrentCamera:WorldToScreenPoint(game.Workspace.Part.Position)
print(position.x,position.y,"It is ".. tostring(onscreen) .." that the part is on screen") -- 1300,1200, It is true that the part is on screen
--if onscreen==false and script.Parent.ScreenGui.Frame.Position.X.Offset>=-1 and script.Parent.ScreenGui.Frame.Position.Y.Offset>=-1 and script.Parent.ScreenGui.Frame.Position.X.Offset<=1134 and script.Parent.ScreenGui.Frame.Position.Y.Offset<=650 then--I tested it out and these types of if statements work aswell
--if onscreen==false and script.Parent.ScreenGui.Frame.Position.X.Offset<=script.Parent.ScreenGui.AbsoluteSize.X and script.Parent.ScreenGui.Frame.Position.Y.Offset<=script.Parent.ScreenGui.AbsoluteSize.Y then
--if onscreen==false and script.Parent.ScreenGui.Frame.Position.X.Offset>=-1 and script.Parent.ScreenGui.Frame.Position.Y.Offset>=-1 then
if onscreen==false then
print("t1")
script.Parent.ScreenGui.Frame.Position = UDim2.new(0,position.x,0,position.y)
--This goes to the opposite point
elseif onscreen==true then
print("t2")
--script.Parent.ScreenGui.Frame.Position = UDim2.new(0,0,0,0)
end
end |