Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Ball = script.Parent;
- local Tool = Ball.Parent;
- local Capture = Tool.Capture
- local Player = Tool.Player
- local Players = Tool.Players
- local Gui = Tool.Gui
- local cpt = Tool.Cpt:Clone()
- local rls = Tool.Rls:Clone()
- function Cam(Player, Subject)
- local new_script = script.Camera:clone()
- new_script.Disabled = false
- new_script.Sub.Value = Subject
- new_script = new_script:clone()
- new_script.Parent = Player
- wait(0.04)
- end
- function removeGui(gui)
- for i = 0.2, 1, .1 do
- gui.BackgroundTransparency = i
- wait(0.075)
- end
- gui.Parent:remove()
- end
- function onTouch(hit)
- connection:disconnect()
- if Capture.Value == true then --when released
- Ball.Anchored = true
- local c = Instance.new("Smoke")
- c.Parent = Ball
- c.RiseVelocity = 4
- rls.Parent = Ball
- wait(2)
- if Players.Value and Gui.Value then
- removeGui(Gui.Value.TextLabel)
- Cam(Players.Value.Backpack, Player.Value.Humanoid)
- end
- --wait(.04)
- Player.Value.Parent = Workspace
- Player.Value:makeJoints()
- if Player.Value:IsA("Model") then
- Player.Value:MoveTo(Ball.Position)
- elseif Player.Value:IsA("BasePart") then
- Player.Value.CFrame = Ball.CFrame + Vector3.new(0, 5, 0)
- else
- Player.Value.Parent = Workspace
- print("Cannot move type "..Player.Value.className)
- end
- Ball.Release.Volume = 1
- Ball.Release:Play()
- --wait(0.3)
- --c:remove()
- Capture.Value = false
- Player.Value = nil
- Tool.Name = "Pokeball"
- Ball:remove()
- else
- local humanoid = hit.Parent:findFirstChild("Humanoid")
- if humanoid and humanoid.Parent ~= Tool.Parent then --when caught
- local spark = Instance.new("Sparkles")
- Ball.Anchored = true
- cpt.Parent = Ball
- spark.Parent = Ball
- spark.Color = Color3.new(1, 0, 0)
- Capture.Value = true
- Player.Value = humanoid.Parent
- Ball.CaptureSound.Volume = 1
- Ball.CaptureSound:Play()
- Tool.Name = Player.Value.Name
- Players.Value = game.Players:GetPlayerFromCharacter(humanoid.Parent)
- if Players.Value then
- Gui.Value = Tool.CaptureGui:clone()
- Gui.Value.Parent = Players.Value.PlayerGui
- Cam(Players.Value.Backpack, Tool.Handle)
- end
- --wait(.04)
- humanoid.Parent.Parent = game.Lighting
- wait(2)
- Ball:remove()
- else
- wait(2)
- Ball:remove()
- end
- end
- end
- connection = Ball.Touched:connect(onTouch)
- local debounce = false
- function getPlayer(humanoid)
- local players = game.Players:children()
- for i = 1, #players do
- if players[i].Character.Humanoid == humanoid then return players[i] end
- end
- return nil
- end
- function onTouch(part)
- local human = part.Parent:findFirstChild("Humanoid")
- if (human ~= nil) and debounce == false then
- debounce = true
- local player = getPlayer(human)
- if (player == nil) then return end
- script.Parent:clone().Parent = player.Backpack
- wait(2)
- debounce = false
- end
- end
- script.Parent.Parent.Touched:connect(onTouch)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement