Duck Hunt Clay Shooting (Lua Sandbox Place 1)

Run Settings
LanguageLua
Language Version
Run Command
DuckHuntGUI = Instance.new("ScreenGui") Background = Instance.new("ImageLabel") Disc = Instance.new("ImageButton") HUD = Instance.new("ImageLabel") Score = Instance.new("Frame") Amount = Instance.new("TextLabel") Text = Instance.new("TextLabel") Misc = Instance.new("Folder") HitText = Instance.new("TextLabel") FullBoard = Instance.new("ImageLabel") ShotText = Instance.new("TextLabel") Bullets = Instance.new("Folder") Bullet1 = Instance.new("ImageLabel") Bullet2 = Instance.new("ImageLabel") Bullet3 = Instance.new("ImageLabel") Pellets = Instance.new("Folder") Pellet1 = Instance.new("ImageLabel") Pellet2 = Instance.new("ImageLabel") Pellet3 = Instance.new("ImageLabel") Pellet4 = Instance.new("ImageLabel") Pellet5 = Instance.new("ImageLabel") Pellet6 = Instance.new("ImageLabel") Pellet7 = Instance.new("ImageLabel") Pellet8 = Instance.new("ImageLabel") Pellet9 = Instance.new("ImageLabel") Pellet10 = Instance.new("ImageLabel") fireinthehole = Instance.new("ImageLabel") Disclaimer = Instance.new("TextLabel") MissDetection = Instance.new("TextButton") DuckHuntGUI.ZIndexBehavior = Enum.ZIndexBehavior.Sibling DuckHuntGUI.Parent = game:GetService("Lighting") DuckHuntGUI.IgnoreGuiInset = true DuckHuntGUI.DisplayOrder = (2^31)-1 DuckHuntGUI.Name = "DuckHuntGUI" Background.Name = "Background" Background.Parent = DuckHuntGUI Background.Position = UDim2.new(0.5, 0, 0, 0) Background.Size = UDim2.new(1, 0, 1, 0) Background.AnchorPoint = Vector2.new(0.5, 0) Background.BackgroundTransparency = 1 Background.SizeConstraint = Enum.SizeConstraint.RelativeYY Background.Image = "rbxassetid://15958461071" Disc.Name = "Disc" Disc.Parent = Background Disc.Visible = false Disc.Size = UDim2.new(0.15, 0, 0.15, 0) Disc.BackgroundTransparency = 1 Disc.ZIndex = HUD.ZIndex - 1 Disc.Image = "rbxassetid://15958688462" HUD.Name = "BottomHUD" HUD.Parent = Background HUD.Size = UDim2.new(1, 0, 1, 0) HUD.BackgroundTransparency = 1 HUD.Image = "rbxassetid://15964659008" HUD.ZIndex = 3 Score.Name = "Score" Score.Parent = HUD Score.Position = UDim2.new(0.74000001, 0, 0.899999976, 0) Score.Size = UDim2.new(0.200000003, 0, 0.075000003, 0) Score.BackgroundColor3 = Color3.new(1, 1, 1) Score.BackgroundTransparency = 1 Score.ZIndex = 2 Amount.Name = "Amount" Amount.Parent = Score Amount.Position = UDim2.new(0, 0, 2.4373644e-06, 0) Amount.Size = UDim2.new(1, 0, 0.75, 0) Amount.BackgroundTransparency = 1 Amount.FontFace = Font.new("rbxasset://fonts/families/PressStart2P.json",Enum.FontWeight.Bold,Enum.FontStyle.Normal) Amount.Text = "000000" Amount.TextColor3 = Color3.new(1, 1, 1) Amount.TextScaled = true Amount.TextWrap = true Amount.TextWrapped = true Amount.TextXAlignment = Enum.TextXAlignment.Right Text.Name = "Text" Text.Parent = Score Text.Position = UDim2.new(0, 0, 0.699999988, 0) Text.Size = UDim2.new(1, 0, 0.300000012, 0) Text.BackgroundTransparency = 1 Text.FontFace = Font.new("rbxasset://fonts/families/PressStart2P.json",Enum.FontWeight.Bold,Enum.FontStyle.Normal) Text.Text = "SCORE" Text.TextColor3 = Color3.new(1, 1, 1) Text.TextScaled = true Text.TextWrap = true Text.TextWrapped = true Misc.Name = "Misc" Misc.Parent = HUD HitText.Name = "HitText" HitText.Parent = Misc HitText.Position = UDim2.new(0.248818904, 0, 0.898779571, 0) HitText.Size = UDim2.new(0.113385826, 0, 0.0480943583, 0) HitText.BackgroundTransparency = 1 HitText.FontFace = Font.new("rbxasset://fonts/families/PressStart2P.json",Enum.FontWeight.Bold,Enum.FontStyle.Normal) HitText.Text = "HIT" HitText.TextColor3 = Color3.new(0.333333, 0.666667, 0) HitText.TextScaled = true HitText.TextWrap = true HitText.TextWrapped = true FullBoard.Name = "Misc" FullBoard.Parent = Misc FullBoard.Visible = false FullBoard.Size = UDim2.new(1, 0, 1, 0) FullBoard.BackgroundColor3 = Color3.new(1, 1, 1) FullBoard.BackgroundTransparency = 1 FullBoard.ZIndex = 0 FullBoard.Image = "rbxassetid://15959029839" ShotText.Name = "ShotText" ShotText.Parent = HUD ShotText.Position = UDim2.new(0.0803149641, 0, 0.931850731, 0) ShotText.Size = UDim2.new(0.116535433, 0, 0.0415747464, 0) ShotText.BackgroundTransparency = 1 ShotText.FontFace = Font.new("rbxasset://fonts/families/PressStart2P.json",Enum.FontWeight.Bold,Enum.FontStyle.Normal) ShotText.Text = "SHOT" ShotText.TextColor3 = Color3.new(0, 0.705882, 0.705882) ShotText.TextScaled = true ShotText.TextStrokeColor3 = Color3.new(0.517647, 0.517647, 0.517647) ShotText.TextWrap = true ShotText.TextWrapped = true Bullets.Name = "Bullets" Bullets.Parent = Background Bullet1.Name = "1" Bullet1.Parent = Bullets Bullet1.Position = UDim2.new(0.0949999988, 0, 0.904999971, 0) Bullet1.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Bullet1.BackgroundTransparency = 1 Bullet1.LayoutOrder = 1 Bullet1.ZIndex = 4 Bullet1.Image = "rbxassetid://15964492417" Bullet2.Name = "2" Bullet2.Parent = Bullets Bullet2.Position = UDim2.new(0.124921277, 0, 0.904999971, 0) Bullet2.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Bullet2.BackgroundTransparency = 1 Bullet2.LayoutOrder = 2 Bullet2.ZIndex = 4 Bullet2.Image = "rbxassetid://15964492417" Bullet3.Name = "3" Bullet3.Parent = Bullets Bullet3.Position = UDim2.new(0.154842541, 0, 0.904999971, 0) Bullet3.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Bullet3.BackgroundTransparency = 1 Bullet3.LayoutOrder = 3 Bullet3.ZIndex = 4 Bullet3.Image = "rbxassetid://15964492417" Pellets.Name = "Pellets" Pellets.Parent = Background Pellet1.Name = "1" Pellet1.Parent = Pellets Pellet1.Position = UDim2.new(0.375, 0, 0.908999979, 0) Pellet1.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Pellet1.BackgroundTransparency = 1 Pellet1.LayoutOrder = 1 Pellet1.ZIndex = 4 Pellet1.Image = "rbxassetid://15964548694" Pellet2.Name = "2" Pellet2.Parent = Pellets Pellet2.Position = UDim2.new(0.405000001, 0, 0.908999979, 0) Pellet2.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Pellet2.BackgroundTransparency = 1 Pellet2.LayoutOrder = 2 Pellet2.ZIndex = 4 Pellet2.Image = "rbxassetid://15964548694" Pellet3.Name = "3" Pellet3.Parent = Pellets Pellet3.Position = UDim2.new(0.434921235, 0, 0.908999979, 0) Pellet3.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Pellet3.BackgroundTransparency = 1 Pellet3.LayoutOrder = 3 Pellet3.ZIndex = 4 Pellet3.Image = "rbxassetid://15964548694" Pellet4.Name = "4" Pellet4.Parent = Pellets Pellet4.Position = UDim2.new(0.465000004, 0, 0.908999979, 0) Pellet4.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Pellet4.BackgroundTransparency = 1 Pellet4.LayoutOrder = 4 Pellet4.ZIndex = 4 Pellet4.Image = "rbxassetid://15964548694" Pellet5.Name = "5" Pellet5.Parent = Pellets Pellet5.Position = UDim2.new(0.497999996, 0, 0.908999979, 0) Pellet5.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Pellet5.BackgroundTransparency = 1 Pellet5.LayoutOrder = 5 Pellet5.ZIndex = 4 Pellet5.Image = "rbxassetid://15964548694" Pellet6.Name = "6" Pellet6.Parent = Pellets Pellet6.Position = UDim2.new(0.52700001, 0, 0.908999979, 0) Pellet6.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Pellet6.BackgroundTransparency = 1 Pellet6.LayoutOrder = 6 Pellet6.ZIndex = 4 Pellet6.Image = "rbxassetid://15964548694" Pellet7.Name = "7" Pellet7.Parent = Pellets Pellet7.Position = UDim2.new(0.559000015, 0, 0.908999979, 0) Pellet7.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Pellet7.BackgroundTransparency = 1 Pellet7.LayoutOrder = 7 Pellet7.ZIndex = 4 Pellet7.Image = "rbxassetid://15964548694" Pellet8.Name = "8" Pellet8.Parent = Pellets Pellet8.Position = UDim2.new(0.589999974, 0, 0.908999979, 0) Pellet8.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Pellet8.BackgroundTransparency = 1 Pellet8.LayoutOrder = 8 Pellet8.ZIndex = 4 Pellet8.Image = "rbxassetid://15964548694" Pellet9.Name = "9" Pellet9.Parent = Pellets Pellet9.Position = UDim2.new(0.621999979, 0, 0.908999979, 0) Pellet9.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Pellet9.BackgroundTransparency = 1 Pellet9.LayoutOrder = 9 Pellet9.ZIndex = 4 Pellet9.Image = "rbxassetid://15964548694" Pellet10.Name = "10" Pellet10.Parent = Pellets Pellet10.Position = UDim2.new(0.652999997, 0, 0.908999979, 0) Pellet10.Size = UDim2.new(0.0299999993, 0, 0.0299999993, 0) Pellet10.BackgroundTransparency = 1 Pellet10.LayoutOrder = 10 Pellet10.ZIndex = 4 Pellet10.Image = "rbxassetid://15964548694" fireinthehole.Name = "fireinthehole" fireinthehole.Parent = DuckHuntGUI fireinthehole.Size = UDim2.new(1, 0, 1, 0) fireinthehole.BackgroundColor3 = Color3.new(0, 0, 0) fireinthehole.BorderSizePixel = 0 fireinthehole.ZIndex = 0 fireinthehole.Image = "rbxassetid://10198213112" fireinthehole.ImageTransparency = 0.98 Disclaimer.Name = "Disclaimer" Disclaimer.Position = UDim2.fromScale(0,.1) Disclaimer.Size = UDim2.fromScale(1,.05) Disclaimer.BackgroundTransparency = 1 Disclaimer.TextColor3 = Color3.new(1,1,1) Disclaimer.TextScaled = true Disclaimer.FontFace = Font.new("rbxasset://fonts/families/PressStart2P.json",Enum.FontWeight.Bold,Enum.FontStyle.Normal) Disclaimer.Text = "Press M to stop script" Disclaimer.Parent = DuckHuntGUI MissDetection.Name = "MissDetection" MissDetection.Size = UDim2.fromScale(1,1) MissDetection.BackgroundTransparency = 1 MissDetection.Text = "" MissDetection.ZIndex = -1 MissDetection.Parent = Background DuckHuntGUI.Parent = script local soundFile = Instance.new("Sound") soundFile.SoundId = "rbxassetid://15979519593" soundFile.Parent = script local textBox = Instance.new("TextBox") textBox.BackgroundTransparency = 0 textBox.BackgroundColor3 = Color3.new(1,1,1) textBox.Size = UDim2.fromScale(.2,.2) textBox.Position = UDim2.fromScale(.5,.5) textBox.AnchorPoint = Vector2.new(.5,.5) textBox.Text = "" textBox.PlaceholderText = "insert sound here" textBox.Name = "SoundDebugger" textBox.ZIndex = 2 textBox.Visible = false textBox.Parent = DuckHuntGUI --script.Name = "DuckHuntClient" local UIS = game:GetService("UserInputService") local mouse = owner:GetMouse() local random = Random.new() local textBox = script.DuckHuntGUI.SoundDebugger local hoverIcon = Instance.new("ImageLabel") local speed = 1 UIS.InputBegan:Connect(function(input,typing) if typing then return end if input.KeyCode == Enum.KeyCode.M then script:Destroy() end end) --owner.Chatted:Connect(function(msg) -- print(string.sub(msg,6)) -- playSoundOfType(string.sub(msg,6)) --end) --owner:GetMouse().Icon = "rbxassetid://116935877" -- this will not work when hovering buttons UIS.MouseIconEnabled = false script.Destroying:Connect(function() UIS.MouseIconEnabled = true hoverIcon:Destroy() end) local mouseLocation = UIS:GetMouseLocation() hoverIcon.Position = UDim2.fromOffset(mouseLocation) hoverIcon.Name = "hoverIconLabel" hoverIcon.Image = "http://www.roblox.com/asset?id=5463262900" hoverIcon.BackgroundTransparency = 1 hoverIcon.BorderSizePixel = 0 hoverIcon.Size = UDim2.fromScale(.1,.1) hoverIcon.AnchorPoint = Vector2.new(0.5, 0.5) hoverIcon.ZIndex = (2^31)-1 hoverIcon.Parent = script.DuckHuntGUI Instance.new("UIAspectRatioConstraint", hoverIcon) mouse.Move:Connect(function() mouseLocation = UIS:GetMouseLocation() hoverIcon.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y) --Constantly changes the position of the mouse game:GetService("RunService").RenderStepped:Wait() end) local sounds = { ["start"] = {0,6}; ["roundstart"] = {6,7.8}; ["roundend"] = {8,10}; ["tally"] = {10.2,11}; ["pause"] = {11.5,12}; ["bark"] = {12.9,14}; ["quack"] = {14,15}; ["duckhit"] = {15,16}; ["disclaunch"] = {16.4,17}; ["gameover"] = {17.5,19.9}; ["shot"] = {20.25,22}; ["dischit"] = {22.75,23.9}; ["flap"] = {24,24.5}; ["doglaugh"] = {25,27}; ["duckfall"] = {27,29}; ["discmoving"] = {30,35.5}; ["nextround"] = {37,41}; ["jingle"] = {43,47}; } local function playSoundOfType(soundtype) if sounds[soundtype] then soundFile.Volume = 5 if soundtype == "bark" or soundtype == "quack" or soundtype == "dischit" then soundFile.Volume = 10 end local clone = soundFile:Clone() clone.Name = soundtype clone.TimePosition = sounds[soundtype][1] clone:Play() clone.Parent = soundFile.Parent task.wait(sounds[soundtype][2]-sounds[soundtype][1]) if clone then clone:Destroy() end end end local function stopSoundOfType(soundtype) if sounds[soundtype] then if soundFile.Parent:FindFirstChild(soundtype) then soundFile.Parent[soundtype]:Destroy() end end end --textBox.FocusLost:Connect(function() -- playSoundOfType(textBox.Text) --end) local StartPositions = { ["Size"] = UDim2.fromScale(0.15,0.15); [1] = { ["Position"] = UDim2.fromScale(0.035,0.85); }; [2] = { ["Position"] = UDim2.fromScale(0.835,0.85); } } local EndPositions = { ["Size"] = UDim2.fromScale(0.05,0.05); [1] = { ["Position"] = UDim2.fromScale(0.875,0.02); }; [2] = { ["Position"] = UDim2.fromScale(0.075,0.2) } } local pos = 1 local score = 0 local function reward(increase,obj) if obj then local txt = Instance.new("TextLabel") txt.BackgroundTransparency = 1 txt.Text = tostring(increase) txt.TextColor3 = Color3.new(1,1,1) txt.FontFace = Font.new("rbxasset://fonts/families/PressStart2P.json",Enum.FontWeight.Bold) txt.AnchorPoint = Vector2.new(.5,.5) txt.Size = UDim2.fromScale(.05,.05) txt.Position = UDim2.new(hoverIcon.Position.X,hoverIcon.Position.Y-txt.Size.Y) txt.TextScaled = true txt.ZIndex = obj.ZIndex+1 txt.Parent = DuckHuntGUI local tween = game:GetService("TweenService"):Create(txt,TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.In),{Position = UDim2.new(txt.Position.X,txt.Position.Y-txt.Size.Y),TextTransparency = 1}) tween:Play() tween.Completed:Connect(function() txt:Destroy() end) end score = score + increase Amount.Text = string.sub("000000",tostring(score):len())..tostring(score) end local bulletsLeft = 3 local objectsHit = 0 local function modifyBullets() bulletsLeft = bulletsLeft - 1 if bulletsLeft == 2 then Bullet3.Visible = false end if bulletsLeft == 1 then Bullet2.Visible = false end if bulletsLeft <= 0 then bulletsLeft = 0 Bullet1.Visible = false return false end return true end local function modifyHits() objectsHit = objectsHit + 1 Pellets[tostring(objectsHit)].Image = "rbxassetid://15964612128" if objectsHit == 10 then return true end end local function makeDisc() if pos > 2 then pos = 1 end local DiscClone = Disc:Clone() DiscClone.Parent = Disc.Parent DiscClone.Visible = true local randomPos1 = random:NextNumber(0,.85) local randomPos2 = random:NextNumber(0,.95) DiscClone.Position = UDim2.fromScale(randomPos1,StartPositions[pos].Position.Y.Scale) DiscClone.Size = StartPositions["Size"] local tween = game:GetService("TweenService"):Create(DiscClone,TweenInfo.new(1.5/speed,Enum.EasingStyle.Linear,Enum.EasingDirection.In),{Position = UDim2.new(randomPos2,EndPositions[pos]["Position"].Y.Scale);Size = EndPositions["Size"]}) tween:Play() DiscClone:SetAttribute("Clicked",false) DiscClone.MouseButton1Down:Once(function() if bulletsLeft >= 1 then task.spawn(function() playSoundOfType("dischit") end) reward(1000,DiscClone) DiscClone:SetAttribute("Clicked",true) Background.Visible = false tween:Pause() local discFrame = Instance.new("Frame") discFrame.BackgroundColor3 = Color3.new(1,1,1) discFrame.BorderSizePixel = 0 discFrame.Size = UDim2.fromScale(.1,.1) discFrame.Position = hoverIcon.Position discFrame.AnchorPoint = Vector2.new(.5,.5) discFrame.Parent = DuckHuntGUI Instance.new("UIAspectRatioConstraint",discFrame) task.wait(tonumber(game:GetService("RunService").RenderStepped:Wait())*4) discFrame:Destroy() DiscClone:Destroy() stopSoundOfType("discmoving") Background.Visible = true modifyHits() end modifyBullets() end) task.spawn(function() playSoundOfType("disclaunch") end) task.spawn(function() tween.Completed:Wait() if DiscClone then if DiscClone:GetAttribute("Clicked") == false then reward(600,DiscClone) end DiscClone:Destroy() stopSoundOfType("discmoving") playSoundOfType("shot") end end) task.spawn(function() playSoundOfType("discmoving") end) end local function alert(length,text) local clone = Disclaimer:Clone() clone.Name = "Alert" clone.AnchorPoint = Vector2.new(.5,.5) clone.Position = UDim2.fromScale(.5,.5) clone.Text = text clone.Parent = Disclaimer.Parent task.spawn(function() while clone do clone.TextColor = BrickColor.random() task.wait(.1) end end) game:GetService("Debris"):AddItem(clone,length) end playSoundOfType("start") MissDetection.MouseButton1Down:Connect(function() if bulletsLeft >= 1 then Background.Visible = false MissDetection.Visible = false local missedFrame = Instance.new("Frame") missedFrame.BackgroundColor3 = Color3.new(1,1,1) missedFrame.BorderSizePixel = 0 missedFrame.Size = UDim2.fromScale(.1,.1) missedFrame.Position = hoverIcon.Position missedFrame.AnchorPoint = Vector2.new(.5,.5) missedFrame.Parent = DuckHuntGUI Instance.new("UIAspectRatioConstraint",missedFrame) task.spawn(function() playSoundOfType("shot") end) task.wait(tonumber(game:GetService("RunService").RenderStepped:Wait())*4) missedFrame:Destroy() MissDetection.Visible = true Background.Visible = true end modifyBullets() end) for i, v in pairs(DuckHuntGUI:GetDescendants()) do if v:IsA("ImageLabel") then v.ResampleMode = Enum.ResamplerMode.Pixelated end end local discsMade = 0 while true do discsMade = 0 bulletsLeft = 3 repeat makeDisc() discsMade = discsMade + 1 pos = pos + 1 task.wait(2) until discsMade >= 2 or objectsHit >= 10 if objectsHit >= 10 then objectsHit = 0 task.wait(.1) alert((sounds["roundend"][2]-sounds["roundend"][1])-.1,"Round complete!") speed=(speed+0.2) playSoundOfType("roundend") task.wait(.25) objectsHit = 0 for i, v in pairs(Pellets:GetChildren()) do v.Image = "rbxassetid://15964548694" end for i, v in pairs(Bullets:GetChildren()) do if v:IsA("ImageLabel") then v.Visible = true end end playSoundOfType("roundstart") end for i, v in pairs(Bullets:GetChildren()) do if v:IsA("ImageLabel") then v.Visible = true end end end
Editor Settings
Theme
Key bindings
Full width
Lines