Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UserInputService = game:GetService('UserInputService')
- local ReplicatedStorage= game:GetService('ReplicatedStorage')
- local Players = game:GetService('Players')
- local Player = Players.LocalPlayer
- local Camera = workspace.CurrentCamera
- local Tortoise = require(game:GetService('ReplicatedStorage').TS)
- local Reticle = Tortoise.Input.Reticle
- local Character = Tortoise.Characters
- local Teams = Tortoise.Teams
- local Systemprojectiles = Tortoise.Projectiles
- local WeaponData = { }
- for Client, userConfig in next, ReplicatedStorage.Items.Base:GetChildren( ) do
- local config = userConfig:FindFirstChild('Config', true)
- if config then WeaponData[userConfig.Name] = require(config) end
- end
- local bulletInfo = getupvalue(Systemprojectiles.InitProjectile, 1)
- local function getBulletData()
- local me = Character:GetCharacter(Player)
- local backPack = me and me:FindFirstChild('Backpack')
- if not backPack then return end
- local equipped = backPack:FindFirstChild('Equipped')
- if not equipped then return end
- local projectile = WeaponData[tostring(equipped.Value)]
- if not projectile or not projectile.Projectile then return end
- return bulletInfo[projectile.Projectile.Template]
- end
- local function Attack(part)
- local distance = (part.Position - Camera.CFrame.Position).magnitude
- local bulletData = getBulletData( )
- if not bulletData then return end
- local timeToHit = distance / bulletData.Speed
- local velocity = part.Velocity + Vector3.new(0, bulletData.Gravity * (timeToHit/2), 0)
- local hitPosition = part.Position + (velocity * timeToHit)
- return hitPosition
- end
- local function nearestTarget(bone : string)
- local info = {
- distance = math.huge,
- player = nil,
- character = nil,
- bone = nil
- }
- for _, player in next, Players:GetPlayers() do
- if player == Player then continue end
- local areFriendly = Teams:ArePlayersFriendly(player, Player)
- local character = Character:GetCharacter(player)
- local body = (character and character:FindFirstChild('Body'))
- local bone = (body) and (body:FindFirstChild(bone))
- if areFriendly or not bone then continue end
- local screenPoint, onScreen = Camera:WorldToScreenPoint(bone.Position)
- if not onScreen then continue end
- local mousePosition = UserInputService:GetMouseLocation()
- local distance = (Vector2.new(screenPoint.x, screenPoint.y) - mousePosition).magnitude
- if distance > info.distance then continue end
- info = {
- distance = distance,
- player = player,
- character = character,
- bone = bone
- }
- end
- return info
- end
- local sightreticleLookVector = Reticle.LookVector
- Reticle.LookVector = function(...)
- local nearest = nearestTarget('Head')
- if nearest.player then
- local ArrowPridiction = Attack(nearest.bone)
- if ArrowPridiction then
- return CFrame.new(Camera.CFrame.Position, ArrowPridiction).LookVector
- end
- end
- return sightreticleLookVector(...)
- end
- setupvalue(Reticle.GetPosition, 1, Reticle.LookVector)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement