Untitled
unknown
plain_text
4 years ago
3.1 kB
6
Indexable
local RemoteEvents = game:GetService("ReplicatedStorage").Events local BarrelThrow = RemoteEvents.Mine local Debris = game:GetService("Debris") local ReplicatedStorage = game:GetService("ReplicatedStorage") local REMOTES = ReplicatedStorage.Remotes local MODULES = ReplicatedStorage.Modules local DAMAGE = require(MODULES.Damage) local EVENTS = ReplicatedStorage:WaitForChild("Events") local newProjectile = script.Parent local isTouched = false script.Parent.Touch.Touched:Connect(function(hit) if not isTouched then if hit.Parent then if hit.Parent:FindFirstChild("Humanoid") then local player = script.Parent.Owner.Value --send raycast-- for i,v in pairs(game.Players:GetPlayers()) do local damage = 60 local originc = newProjectile.CFrame --ray start pos local targetc = v.Character.HumanoidRootPart.CFrame --ray target local startPosition = newProjectile.Position --ray start pos local lookAt = v.Character.HumanoidRootPart.Position --towards where the ray looks local distance = (startPosition - lookAt).magnitude --how far the ray goes local raycastParams = RaycastParams.new() raycastParams.FilterDescendantsInstances = {newProjectile} raycastParams.FilterType = Enum.RaycastFilterType.Blacklist local offset = Vector3.new(0,0,0) local ray = workspace:Raycast(startPosition, (lookAt-startPosition).Unit * distance*1.4, raycastParams) local raylength = (startPosition - v.Character.HumanoidRootPart.Position).Magnitude if v.TeamColor == BrickColor.new("Bright blue") then game.ReplicatedStorage.Remotes.Effect:FireAllClients("Explosion", newProjectile.Position, 10) if ray then print("ray hit: ", ray.Instance.AssemblyRootPart.Parent.Name) print("how far away: ", raylength, " studs") if raylength < 8 then v.Character.Humanoid:TakeDamage(damage) REMOTES.HitIndicator:FireClient(v, offset, damage) --DAMAGE:Damage(v.Character.Humanoid, damage, player) REMOTES.Hitmarker:FireClient(player, v.Character.Head.Position, damage, v.Character.Humanoid:FindFirstChild("Armor")) elseif raylength < 15 then v.Character.Humanoid:TakeDamage(damage*0.8) REMOTES.HitIndicator:FireClient(v, offset, damage*0.8) --DAMAGE:Damage(v.Character.Humanoid, damage*0.8, player) REMOTES.Hitmarker:FireClient(player, v.Character.Head.Position, damage*0.8, v.Character.Humanoid:FindFirstChild("Armor")) elseif raylength < 22 then v.Character.Humanoid:TakeDamage(damage*0.5) REMOTES.HitIndicator:FireClient(v, offset, damage*0.5) --DAMAGE:Damage(v.Character.Humanoid, damage*0.5, player) REMOTES.Hitmarker:FireClient(player, v.Character.Head.Position, damage*0.5, v.Character.Humanoid:FindFirstChild("Armor")) end else print("not hitting") end newProjectile:Destroy() end end end end end wait(1) isTouched = false end)
Editor is loading...