Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local Player = Players.LocalPlayer
- local puddleGroup = workspace:FindFirstChild("ActiveCastleStage"):FindFirstChild('CastleFloor1'):FindFirstChild('ActivePuddle')
- local PathfindingService = game:GetService("PathfindingService")
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local path = PathfindingService:CreatePath()
- local player = Players.LocalPlayer
- local character = player.Character
- local humanoid = character:WaitForChild("Humanoid")
- local TEST_DESTINATION = Vector3.new(100, 0, 100)
- local waypoints
- local nextWaypointIndex
- local reachedConnection
- local blockedConnection
- local dis2 = function(x1,x2,y1,y2,z1,z2)
- return math.sqrt(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1))+((z2-z1)*(z2-z1)))
- end
- local function getMop()
- keypress(0x6F)
- keyrelease(0x6F) -- /
- wait(1)
- keypress(0xBA)
- keyrelease(0xBA) -- ;
- keypress(0x4D)
- keyrelease(0x4D) -- m
- wait(0.1)
- keypress(0x4F)
- keyrelease(0x4F) -- o
- wait(0.1)
- keypress(0x50)
- keyrelease(0x50) -- p
- wait(0.1)
- keypress(0x0D)
- keyrelease(0x0D) -- enter
- wait(0.5)
- if not Player.Backpack:FindFirstChild("Mop") and not Player.Character:FindFirstChild("Mop") then
- getMop()
- else
- Player.Character.HumanoidRootPart.CFrame = CFrame.new(43.6898956, 17.8257427, -5.62305498, -0.999780715, 3.15323732e-08, 0.0209410898, 3.21309805e-08, 1, 2.82489783e-08, -0.0209410898, 2.89156414e-08, -0.999780715)
- run = true
- return true;
- end
- end
- for _,v in pairs(workspace:FindFirstChild("ActiveCastleStage"):FindFirstChild('CastleFloor1'):GetDescendants()) do
- if v.Name == "Door" then
- v:Destroy()
- end
- end
- local bambam = Instance.new("BodyThrust")
- bambam.Parent = Player.Character.HumanoidRootPart
- bambam.Force = Vector3.new(0,0,0)
- bambam.Location = Player.Character.HumanoidRootPart.Position
- local elapsed_time = 0
- local function followPath(destination)
- -- Compute the path
- local success, errorMessage = pcall(function()
- path:ComputeAsync(character.PrimaryPart.Position, destination)
- end)
- if success and path.Status == Enum.PathStatus.Success then
- -- Get the path waypoints
- waypoints = path:GetWaypoints()
- -- Detect if path becomes blocked
- blockedConnection = path.Blocked:Connect(function(blockedWaypointIndex)
- -- Check if the obstacle is further down the path
- if blockedWaypointIndex >= nextWaypointIndex then
- -- Stop detecting path blockage until path is re-computed
- blockedConnection:Disconnect()
- -- Call function to re-compute new path
- humanoid.Jump = true
- followPath(destination)
- end
- end)
- -- Detect when movement to next waypoint is complete
- if not reachedConnection then
- reachedConnection = humanoid.MoveToFinished:Connect(function(reached)
- if reached and nextWaypointIndex < #waypoints then
- humanoid.Jump = true
- -- Increase waypoint index and move to next waypoint
- nextWaypointIndex = nextWaypointIndex + 1
- humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
- else
- reachedConnection:Disconnect()
- blockedConnection:Disconnect()
- end
- end)
- end
- bambam.Force = Vector3.new(500,0,500)
- -- Initially move to second waypoint (first waypoint is path start; skip it)
- nextWaypointIndex = 2
- humanoid:MoveTo(waypoints[nextWaypointIndex].Position)
- end
- end
- local run = false
- local currentPuddle = nil
- local listener
- local function getPuddle()
- for _,v in pairs(puddleGroup:GetChildren()) do
- if v:IsA("Model") then
- local p1 = Player.Character.HumanoidRootPart.Position
- local p2 = v:FindFirstChildOfClass("Part").Position
- if dis2(p1.X,p2.X,p1.Y,p2.Y,p1.Z,p2.Z) < 175 then
- currentPuddle = v
- listener = currentPuddle:FindFirstChildOfClass("Part").Destroying:Connect(function()
- elapsed_time = 0
- currentPuddle = nil
- end)
- return followPath(v:FindFirstChildOfClass("Part").Position);
- else
- return nil;
- end
- end
- end
- end
- Player.Chatted:Connect(function(msg)
- if msg == ";begin" then
- if Player.Backpack:FindFirstChild("Mop") then
- Player.Backpack:FindFirstChild("Mop").Parent = Player.Character
- Player.Character.HumanoidRootPart.CFrame = CFrame.new(43.6898956, 17.8257427, -5.62305498, -0.999780715, 3.15323732e-08, 0.0209410898, 3.21309805e-08, 1, 2.82489783e-08, -0.0209410898, 2.89156414e-08, -0.999780715)
- run = true
- getPuddle()
- end
- if not Player.Backpack:FindFirstChild("Mop") and not Player.Character:FindFirstChild("Mop") then
- getMop()
- wait(0.1)
- Player.Backpack:FindFirstChild("Mop").Parent = Player.Character
- Player.Character.HumanoidRootPart.CFrame = CFrame.new(43.6898956, 17.8257427, -5.62305498, -0.999780715, 3.15323732e-08, 0.0209410898, 3.21309805e-08, 1, 2.82489783e-08, -0.0209410898, 2.89156414e-08, -0.999780715)
- run = true
- getPuddle()
- end
- if Player.Character:FindFirstChild("Mop") then
- Player.Character.HumanoidRootPart.CFrame = CFrame.new(43.6898956, 17.8257427, -5.62305498, -0.999780715, 3.15323732e-08, 0.0209410898, 3.21309805e-08, 1, 2.82489783e-08, -0.0209410898, 2.89156414e-08, -0.999780715)
- run = true
- getPuddle()
- end
- elseif msg == ";stop" then
- run = false
- bambam.Force = Vector3.new(0,0,0)
- elseif msg == ";gettime" then
- print(elapsed_time)
- end
- end)
- game:GetService('RunService').Heartbeat:Connect(function(dt)
- elapsed_time = elapsed_time + dt
- if currentPuddle == nil and run == true then
- currentPuddle = getPuddle()
- end
- if run == false then
- bambam.Force = Vector3.new(0,0,0)
- end
- if elapsed_time > 60 then
- print("Pathfinding: Time limit has been reached")
- end
- if elapsed_time > 60 and run == true then
- warn("Pathfinding: Gave up on puddle")
- for _,v in pairs(puddleGroup:GetChildren()) do
- if v == currentPuddle then
- listener:Disconnect()
- v:Destroy()
- end
- end
- currentPuddle = nil
- elapsed_time = 0
- Player.Character.HumanoidRootPart.CFrame = CFrame.new(43.6898956, 17.8257427, -5.62305498, -0.999780715, 3.15323732e-08, 0.0209410898, 3.21309805e-08, 1, 2.82489783e-08, -0.0209410898, 2.89156414e-08, -0.999780715)
- end
- end)
- Player.Character.Humanoid.Died:Connect(function()
- getMop()
- Player.Character.HumanoidRootPart.CFrame = CFrame.new(43.6898956, 17.8257427, -5.62305498, -0.999780715, 3.15323732e-08, 0.0209410898, 3.21309805e-08, 1, 2.82489783e-08, -0.0209410898, 2.89156414e-08, -0.999780715)
- getPuddle()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement