Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local plr = game.Players.LocalPlayer
- --ui
- function createStatusUI()
- local statusUI = Instance.new("ScreenGui", plr.PlayerGui)
- statusUI.ResetOnSpawn = false
- statusLabel = Instance.new("TextButton", statusUI)
- statusLabel.Size = UDim2.new(0.1,0,0.1,0)
- statusLabel.Text = "Bot Disabled."
- end
- createStatusUI()
- --
- function dist(obj1, obj2)
- return (obj1.Position - obj2.Position).magnitude
- end
- --bot
- local enemyAttackConnection
- local enemyParryConnection
- function newCharacter(plrChar)
- plrChar.ChildAdded:Connect(function(newChild)
- statusLabel.Text = "Script executed, player found."
- if newChild:FindFirstChild("combatData") then
- statusLabel.Text = "Player lightsaber hooked."
- local plrLightsaber = newChild
- local plrCombatData = plrLightsaber.combatData
- local plrRemoteFolder = plrLightsaber.Assets.Events
- local plrAttackRemote = plrRemoteFolder.attackStart
- local plrCancelAttack = plrRemoteFolder.cancelAttack
- local plrUpdateStance = plrRemoteFolder.updateStance
- local plrTarget = plrCombatData.Target
- local plrAttacking = plrCombatData.Attacking
- local plrParrying = plrCombatData.Parrying
- plrTarget.Changed:Connect(function()
- statusLabel.Text = "Player enemy hooked."
- --disconnect all previous enemy listeners
- if enemyAttackConnection then
- enemyAttackConnection:Disconnect()
- enemyAttackConnection = nil
- end
- if enemyParryConnection then
- enemyParryConnection:Disconnect()
- enemyParryConnection = nil
- end
- --
- if plrTarget.Value ~= nil then
- local enemyLightsaber = nil
- for _,child in pairs(plrTarget.Value:GetChildren()) do
- if child:IsA("Tool") then
- if child:FindFirstChild("combatData") then
- enemyLightsaber = child
- end
- end
- end
- if enemyLightsaber == nil then return end
- local enemyCombatData = enemyLightsaber.combatData
- local enemyAttacking = enemyCombatData.Attacking
- local enemyParrying = enemyCombatData.Parrying
- local enemyStance = enemyCombatData.Stance
- enemyParryConnection = enemyParrying.Changed:Connect(function()
- if dist(enemyLightsaber.Parent.Head,plrLightsaber.Parent.Head) < 9.5 then
- if enemyParrying.Value == true then
- statusLabel.Text = "Enemy attacking."
- plrAttackRemote:FireServer(enemyStance.Value, false)
- wait(0.1)
- if enemyAttacking.Value == false then
- plrCancelAttack:FireServer()
- return
- end
- repeat
- wait()
- until plrAttacking.Value == false
- plrUpdateStance:FireServer(enemyCombatData.Stance.Value, false)
- plrAttackRemote:FireServer(enemyStance.Value-180, false)
- end
- end
- end)
- end
- end)
- end
- end)
- end
- plr.CharacterAdded:Connect(newCharacter)
- --
- --for first time joining the game
- if plr.Character ~= nil then
- newCharacter(plr.Character)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement