Advertisement
Guest User

Untitled

a guest
Jun 13th, 2019
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. local shopPoints = workspace.ServerRef.Lobby.ShopPoints
  2. local shopArea = {shopPoints.Point1.Position, shopPoints.Point2.Position, shopPoints.Point3.Position, shopPoints.Point4.Position, shopPoints.Point5.Position}
  3. local function PointWithinArea(Point, Points)
  4.     local Side
  5.     for i = 1, #Points do
  6.         local Point0 = Points[i]
  7.         local Point1 = Points[i == #Points and 1 or i + 1]
  8.         local Value = (Point1 - Point0):Cross(Point - Point0).Y > 0
  9.         if Side ~= nil and Value ~= Side then
  10.             return false
  11.         end
  12.         Side = Value
  13.     end
  14.     return true
  15. end
  16.  
  17. game.Players.LocalPlayer.CharacterAdded:Connect(function(character)
  18.     character:WaitForChild("HumanoidRootPart")
  19.     character.Humanoid.Changed:Connect(function()
  20.         if PointWithinArea(character.HumanoidRootPart.Position, shopArea) then
  21.             game.Players.LocalPlayer.PlayerGui.MainGameGuis.Shop.Visible = true
  22.         else
  23.             game.Players.LocalPlayer.PlayerGui.MainGameGuis.Shop.Visible = false
  24.         end
  25.     end)
  26. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement