Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How to make Snow Gui?

Asked by 10 years ago

I found a snow gui that is quite nice but how do I make it stop on my screen when I'm inside a building?

local imgs={}
imgs[1]  = "http://www.roblox.com/asset/?id=201925145"
imgs[2]  = "http://www.roblox.com/asset/?id=201925145"
imgs[3]  = "http://www.roblox.com/asset/?id=201925145"
imgs[4]  = "http://www.roblox.com/asset/?id=201925145"
imgs[5]  = "http://www.roblox.com/asset/?id=201925145"
imgs[6]  = "http://www.roblox.com/asset/?id=201925145"
imgs[7]  = "http://www.roblox.com/asset/?id=201925145"
imgs[8]  = "http://www.roblox.com/asset/?id=201925145"
imgs[9]  = "http://www.roblox.com/asset/?id=201925145"
imgs[10] = "http://www.roblox.com/asset/?id=201925145"
imgs[11] = "http://www.roblox.com/asset/?id=201925145"

local q = Instance.new("Part")
q.Anchored = 0
q.formFactor = Enum.FormFactor.Symmetric
q.Size = Vector3.new(1, 1, 1)

function projection(vector, camera, size)
  local abs = math.abs
  local result = camera:toObjectSpace(vector)
  vector = result.p
  local rx, ry, rz = result:toEulerAnglesXYZ()
  if vector.z > 0 then return end
  local sizex = size/abs(vector.z)
  local sizey = sizex * abs(math.cos(rx))
  local sizex = sizex * abs(math.cos(ry))
  return -vector.x / vector.z, vector.y * 1.7071067811865 / vector.z, sizex, sizey
end

local face = Enum.NormalId.Bottom

function getdepth(v)
  local t = q:clone()
  t.Parent = workspace
  t.CFrame = CFrame.new(v)
  local s = 2^5
  local n = 1
  for i = 1, 5 do
    s = s * .5
    if t:Resize(face, s) then
      n = n + s
    end
  end
  t.Parent = nil
  return n
end

local torso
local flakes = {}

function updatesprite(sprite)
  sprite[2] = sprite[2] * CFrame.new(0, -.2, 0) * CFrame.Angles(0, .037699111843078, 0)
  if sprite[2].p.y < sprite[4] then
    sprite:remove()
  end
end

function rendersprite(sprite, cx, cy)
  local px, py, sx, sy = projection(sprite[2],workspace.CurrentCamera.CoordinateFrame, sprite[3])
  local label = sprite[1]
  if px and sx >= 1 and sy >= 1 then
    label.Visible = true
    label.Size = UDim2.new(0,sx,0,sy)
    label.Position = UDim2.new(0,((px + 1) * cx - sx) * .5,0,((py + 1) * cy - sy) * .5)
  else
    label.Visible = false
  end
end

function clear()
  for flake in pairs(flakes) do
    flake:remove()
  end
end

function remove(flake)
  flake[1].Parent = nil
  flakes[flake] = nil
end

function makeflake(pos)
  local label = Instance.new("ImageLabel", script.Parent)
  label.Image = imgs[math.random(1, #imgs)]
  label.BackgroundTransparency = 1
  local dx, dz = (math.random() - .5) * 200, (math.random() - .5) * 200
  local pos = pos + Vector3.new(dx, (30 - math.random() * 20) * (1 - (dx^2 + dz^2)^.5/(1.4142135623731 * 100)) , dz)
  local sphr = CFrame.new(Vector3.new(),Vector3.new(math.random()-.5,0,math.random()-.5)) + pos
  local size = 100 * (math.random() * .75 + .25) * 10
  local sprite = {label, sphr, size, pos.y - getdepth(pos), remove = remove}
  local cz = script.Parent.AbsoluteSize
  local cx, cy = cz.x, cz.y
  rendersprite(sprite, cx, cy)
  flakes[sprite] = 0
end

function spawn(char)
  torso = char.Torso
  clear()
  for i = 1, 50 do
    makeflake(torso.Position)
  end
  while char.Parent do
    wait()
    local cz = script.Parent.AbsoluteSize
    local cx, cy = cz.x, cz.y
    if math.random()<.75 then makeflake(torso.Position)end
    for flake in pairs(flakes) do
      updatesprite(flake)
      rendersprite(flake, cx, cy)
    end
  end
end

repeat wait() until game.Players.LocalPlayer.Character
spawn(game.Players.LocalPlayer.Character)

1 answer

Log in to vote
0
Answered by 10 years ago

In order for us at Scripting Helpers to answer a request or help topic, please make sure you have posted code you developed in order to get where you are in the process of building. I know this may be annoying but in order to cut down the amount of requests we must enforce this rule.

Thank you for your cooperation.

Ad

Answer this question