Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game:GetService'Players'.LocalPlayer
- local soundscript = player.PlayerGui.MainGUI.Scripts.SoundHandler
- local correct = soundscript.Local:FindFirstChild'Correct'
- local registry = getreg or debug.getregistry
- local datamodule = nil
- local running = false
- for k, v in pairs(registry()) do
- if type(v) == "function" then
- local good, ups = pcall(debug.getupvalues, v)
- if good and ups then
- for i, z in next, ups do
- if type(z) == "table" and z.FireServer ~= nil then
- datamodule = z
- break
- end
- end
- end
- end
- end
- assert(datamodule, "DataModule could not be found!")
- local oldfire = datamodule.FireServer
- function datamodule:FireServer(tbl)
- if tbl.Type == "UseHatchet" then
- local rem = datamodule:Get(tbl.Type)
- repeat
- rem:FireServer({Time = math.random(100), Tree = tbl.Tree})
- wait(0.25)
- until (correct.IsPlaying or running == false)
- wait(0.25)
- correct.Playing = false --ugly fix but the sound is like 5 second long for some reason and i was skipping trees becasue of it
- return
- end
- return oldfire(self, tbl)
- end
- game:GetService'UserInputService'.InputBegan:Connect(function(key, processed)
- if key.KeyCode == Enum.KeyCode.L and not processed then
- running = not running
- warn("RUNNING:", running)
- spawn(function()
- while running do
- local char = player.Character or player.CharacterAdded:Wait()
- char.Humanoid.WalkSpeed = 16
- for k, v in ipairs(game:GetService'Workspace'.Trees:GetChildren()) do
- if v.ClassName == "Model" and v.PrimaryPart.Position.Y - char.HumanoidRootPart.Position.Y < 20 then
- repeat
- char.Humanoid:ChangeState(11)
- char.Humanoid:MoveTo(v.PrimaryPart.Position + Vector3.new(2, 0, 0))
- wait()
- until ((char.HumanoidRootPart.Position - v.PrimaryPart.Position).magnitude < 10 or running == false)
- if not running then
- break
- end
- datamodule:FireServer({Type = "UseHatchet", Tree = v})
- end
- end
- end
- end)
- end
- end)
Add Comment
Please, Sign In to add comment