Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DX = 30
- local maxcount = 3
- local DY = math.floor((DX/2)+(DX/16))
- local PX,PY = 1/DX,1/DY
- local spart,screen
- local pixels = {}
- --//=================================\\
- --|| SAZERENOS' ARTIFICIAL HEARTBEAT
- --\\=================================//
- ArtificialHB = Instance.new("BindableEvent", script)
- ArtificialHB.Name = "ArtificialHB"
- script:WaitForChild("ArtificialHB")
- frame = (1/60)
- tf = 0
- allowframeloss = false
- tossremainder = false
- lastframe = tick()
- script.ArtificialHB:Fire()
- game:GetService("RunService").Heartbeat:connect(function(s, p)
- tf = tf + s
- if tf >= frame then
- if allowframeloss then
- script.ArtificialHB:Fire()
- lastframe = tick()
- else
- for i = 1, math.floor(tf / frame) do
- script.ArtificialHB:Fire()
- end
- lastframe = tick()
- end
- if tossremainder then
- tf = 0
- else
- tf = tf - frame * math.floor(tf / frame)
- end
- end
- end)
- function Swait(NUMBER)
- if NUMBER == 0 or NUMBER == nil then
- ArtificialHB.Event:wait()
- else
- for i = 1, NUMBER do
- ArtificialHB.Event:wait()
- end
- end
- end
- --//=================================\\
- --\\=================================//
- function create_screen_pixels()
- spart = Instance.new("Part")
- screen = Instance.new("SurfaceGui")
- spart.Parent = script
- spart.CFrame = CFrame.new(1.15006196, 7.37997007, -0.665921986, -1, 0, 0, 0, 1, 0, 0, 0, -1)
- spart.Orientation = Vector3.new(0, 180, 0)
- spart.Color = Color3.new(0.972549, 0.972549, 0.972549)
- spart.Size = Vector3.new(26.2399158, 14.7599401, 0.151851237)
- spart.Material = Enum.Material.SmoothPlastic
- spart.Anchored = true
- spart.Locked = false
- spart.CanCollide = true
- screen.Parent = spart
- screen.LightInfluence = 1
- screen.ClipsDescendants = true
- screen.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
- screen.Adornee = spart
- for Y = 1,DY do
- for X = 1,DX do
- local size = UDim2.new(PX,0,PY,0)
- local offset = UDim2.new(PX*X-PX,0,PY*Y-PY,0)
- local seat = ((Y-1)*DX+X)
- local pixel = Instance.new("Frame")
- pixel.Parent = screen
- pixel.BorderSizePixel = 0
- pixel.BackgroundColor3 = Color3.new(1,1,1)
- pixel.BorderColor3 = Color3.new()
- pixel.Size = size
- pixel.Position = offset
- table.insert(pixels,seat,pixel)
- Swait()
- end
- end
- end
- function create_screen_parts()
- spart = Instance.new("Part")
- screen = Instance.new("Model")
- spart.Parent = script
- spart.CFrame = CFrame.new(1.15006196, 7.37997007, -0.665921986, -1, 0, 0, 0, 1, 0, 0, 0, -1)
- spart.Orientation = Vector3.new(0, 180, 0)
- spart.Color = Color3.new(0.972549, 0.972549, 0.972549)
- spart.Size = Vector3.new(26.2399158, 14.7599401, 0.151851237)
- spart.Material = Enum.Material.SmoothPlastic
- spart.Anchored = true
- spart.Locked = false
- spart.CanCollide = true
- screen.Parent = spart
- for Y = 1,DY do
- for X = 1,DX do
- local _PX,_PY = spart.Size.X/DX,spart.Size.Y/DY
- local size = Vector3.new(_PX,_PY,1)
- local pos = (spart.Position+Vector3.new(-(spart.Size.X/2),(spart.Size.Y/2),0))-Vector3.new(-(_PX*X-_PX/2),_PY*Y-_PY/2,0)
- local seat = ((Y-1)*DX+X)
- local pixel = Instance.new("Part")
- pixel.Parent = screen
- pixel.Material = Enum.Material.SmoothPlastic
- pixel.Color = Color3.new(1,1,1)
- pixel.Size = size
- pixel.Transparency = 0
- pixel.Anchored = true
- pixel.CanCollide = true
- pixel.Locked = true
- pixel.Position = pos
- table.insert(pixels,seat,pixel)
- Swait()
- end
- end
- end
- function clear_screen()
- for i,pixel in pairs(screen:GetChildren()) do
- if pixel then
- pixel.ZIndex = 1
- pixel.BorderColor3 = Color3.new()
- pixel.BorderSizePixel = 0
- pixel.BackgroundTransparency = 1
- pixel.BackgroundColor3 = Color3.new(1,1,1)
- end;
- end;
- end
- function update_screen_ray_pixels()
- for Y = 1,DY do
- spawn(function()
- for X = 1,DX do
- local _PX,_PY = spart.Size.X/DX,spart.Size.Y/DY
- local pos = (spart.Position+Vector3.new(-(spart.Size.X/2),(spart.Size.Y/2),0))-Vector3.new(-(_PX*X-_PX/2),_PY*Y-_PY/2,0)
- local dist = 20
- local ray = Ray.new(pos,((pos+Vector3.new(0,0,1))-pos).Unit*dist)
- local hit,hitpos = workspace:FindPartOnRayWithIgnoreList(ray,{script},true,true)
- local seat = ((Y-1)*DX+X)
- local pixel = pixels[seat]
- if hit and hit.Parent and not hit.Parent:IsA("Accessory") then
- if pixel then
- if hit.Name == 'HumanoidRootPart' then
- hit = hit.Parent:FindFirstChild("Torso") or hit.Parent:FindFirstChild("UpperTorso")
- if hit then
- local depth = (dist-hitpos.Z)/5
- local depth_color = (hitpos.Z/dist)
- if 1 > depth then
- depth = 1
- end
- pixel.ZIndex = 1+depth
- pixel.BorderColor3 = Color3.new(depth_color,depth_color,depth_color)
- pixel.BorderSizePixel = depth
- pixel.BackgroundTransparency = hit.Transparency
- pixel.BackgroundColor3 = hit.Color
- end
- else--if 1 > hit.Transparency then
- local depth = (dist-hitpos.Z)/5
- local depth_color = (hitpos.Z/dist)
- if 1 > depth then
- depth = 1
- end
- pixel.ZIndex = 1+depth
- pixel.BorderColor3 = Color3.new(depth_color,depth_color,depth_color)
- pixel.BorderSizePixel = depth
- pixel.BackgroundTransparency = hit.Transparency
- pixel.BackgroundColor3 = hit.Color
- end
- end
- elseif pixel then
- pixel.ZIndex = 1
- pixel.BorderColor3 = Color3.new()
- pixel.BorderSizePixel = 0
- pixel.BackgroundTransparency = 1
- pixel.BackgroundColor3 = Color3.new(1,1,1)
- end
- Swait()
- end
- end)
- Swait()
- end
- end
- function create_ray(X,Y,_PX,_PY,pos,count,t)
- local dist = 20/maxcount
- local ray = Ray.new(pos,((pos+Vector3.new(0,0,1))-pos).Unit*dist)
- local hit,hitpos = workspace:FindPartOnRayWithIgnoreList(ray,{script,table.unpack(t)},true,true)
- local seat = ((Y-1)*DX+X)
- local pixel = pixels[seat]
- local found = false
- if hit and hit.Parent and not hit.Parent:IsA("Accessory") then
- if pixel then
- if hit.Name == 'HumanoidRootPart' then
- hit = hit.Parent:FindFirstChild("Torso") or hit.Parent:FindFirstChild("UpperTorso")
- if hit then
- found = true
- pixel.Material = hit.Material
- pixel.Color = hit.Color
- pixel.Transparency = hit.Transparency
- end
- elseif 1 > hit.Transparency then
- found = true
- pixel.Material = hit.Material
- pixel.Color = hit.Color
- pixel.Transparency = hit.Transparency
- end
- end
- elseif pixel then
- pixel.Material = Enum.Material.SmoothPlastic
- pixel.Color = Color3.new(1,1,1)
- pixel.Transparency = 0
- end
- --Swait()
- count = count + 1
- if maxcount >= count and not found then
- create_ray(X,Y,_PX,_PY,hitpos,count,{table.unpack(t),hit})
- end
- end
- function update_screen_ray_parts()
- for Y = 1,DY do
- spawn(function()
- for X = 1,DX do
- local _PX,_PY = spart.Size.X/DX,spart.Size.Y/DY
- local pos = (spart.Position+Vector3.new(-(spart.Size.X/2),(spart.Size.Y/2),0))-Vector3.new(-(_PX*X-_PX/2),_PY*Y-_PY/2,0)
- create_ray(X,Y,_PX,_PY,pos,1,{})
- end
- end)
- Swait()
- end
- end
- --create_screen_parts()
- create_screen_pixels()
- game:GetService("RunService").Stepped:Connect(function()
- --clear_screen()
- --update_screen_ray_parts()
- update_screen_ray_pixels()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement