|
| 15 Nov 2014 07:50 PM |
Hey guys. I have a gunscript here and I added a few places in the script that should tag a killed player when they are killed with the gun. But seems like they aren't getting tagged. So I came here for help after trial and error and trial and error and trail and error, over and over again xD Anyway could someone help find where the actual appropriate area to place a tag when the player is either damaged or killed.
Script:
local debris = game:GetService("Debris") local tuple = {...} local playerhit = tuple[3] local targethumanoid = playerhit.Parent:FindFirstChild("Humanoid")
wait(1) Tool = script.Parent player = game.Players.LocalPlayer
-------------------------------SETTINGS Normal_icon = "http://www.roblox.com/asset/?id=54019936" Friend_icon = "http://www.roblox.com/asset/?id=54019944" Enemy_icon = "http://www.roblox.com/asset/?id=54019939" Reload_icon = "http://www.roblox.com/asset/?id=54020165"
Shot_Color = BrickColor.new("Deep orange") mesh_id = "" texture_id = "" mesh_scale = Vector3.new(0,0,0) bullet_spin = Vector3.new(0,0,0)
Clip_Size = 1
Fire_Speed = 0.1 Reload_Speed = 2.5
Automatic = false Shots_Per_Bullet = 1
Inaccuracy = 1 Distance = 900000 Bullet_Speed = 40 Bullet_Gravity = 0 Distance_With_No_Gravity = 0
Damage = 1000 Head_Damage = 1000
Shoot_From = Vector3.new(0,0,-2) -- From Torso
-- Links to stuff: Shots = game.Workspace:findFirstChild("SHOTS") fire_sound = Tool.Handle:findFirstChild("fire") reload_sound = Tool.Handle:findFirstChild("reload") -------------------------------SETTINGS
--[[ FOR CROSSBOW
mesh_id = "http://www.roblox.com/asset/?id=15887356" texture_id = "http://www.roblox.com/asset/?id=15886781" mesh_scale = Vector3.new(1,1,1) bullet_spin = Vector3.new(0.5,0,0)
--]]
--Shell Settings
cam = game.Workspace.CurrentCamera function GetCamAim() return (cam.CoordinateFrame * CFrame.new(0,0,-100)).p end
function CheckIfZoomed() local pos = cam.CoordinateFrame local head = player.Character:findFirstChild("Head") local dist = (pos.p - head.Position).magnitude if dist < 3.6 then return true else return false end end
shell = Instance.new("Part") shell.CanCollide = false shell.Name = "beam" shell.Anchored = true shell.formFactor = "Custom" shell.Size = Vector3.new(0.3,3,0.3) shell.Reflectance = 0.3 shell.BrickColor = Shot_Color if mesh_id == "" then m = Instance.new("BlockMesh",shell) m.Scale = Vector3.new(0.3,0.8,0.3) else m = Instance.new("SpecialMesh",shell) m.MeshType = "FileMesh" m.Scale = Vector3.new(1,1,1) m.MeshId = mesh_id m.TextureId = texture_id end
--Shell Settings
char = player.Character is_reloading = false last_shot = 0 fireon = false is_reloading = false the_clip = Clip_Size
the_gui = Instance.new("ScreenGui") the_gui.Name = "AmmoGui" ammtxt = Instance.new("TextLabel",the_gui) ammtxt.BackgroundTransparency = 1 ammtxt.Position = UDim2.new(0.5,0,1,-150) ammtxt.TextColor3 = Color3.new(50,50,50) ammtxt.TextStrokeColor3 = Color3.new(255,255,255) ammtxt.Font = "ArialBold" ammtxt.FontSize = "Size24" ammtxt.TextStrokeTransparency = 0 ammtxt.Text = the_clip .. " / " .. Clip_Size
function GetHumanoid(prt) h1 = prt.Parent:findFirstChild("Humanoid") h2 = prt.Parent.Parent:findFirstChild("Humanoid") if h1 ~= nil then return h1 else return h2 end end
--[[ function check_aggressive(pteam1,pteam2) return (pteam1 ~= pteam2) end --]]
function check_aggressive(cl1,cl2) if cl1 == BrickColor.new() or cl2 == BrickColor.new() then return true end tms = game.Teams alt = tms:findFirstChild("T4V Allies").TeamColor t4vt = tms:findFirstChild("T4V Members").TeamColor ent = tms:findFirstChild("Raiders").TeamColor if cl1 == alt or cl1 == t4vt then if cl2 == ent then return true end else if cl1 ~= cl2 then return true end end return false end
function GetPlayerFromHum(hum) pl = game.Players:GetChildren() for i = 1,#pl do if pl[i].Character:findFirstChild("Humanoid") == hum then return pl[i] end end return nil end
function InspectTeam(hum) if GetPlayerFromHum(hum) ~= nil then return GetPlayerFromHum(hum).TeamColor elseif hum.Parent:findFirstChild("AITEAM") ~= nil then return hum.Parent:findFirstChild("AITEAM").Value else return BrickColor.new() end end
function GetPosFromHum(hum) if hum.Parent:findFirstChild("Torso") ~= nil then return hum.Parent:findFirstChild("Torso").Position else return Vector3.new() end end
function MyPos() return char.Torso.Position end
function GiveDamage(Hitted_Part,Normal_Damage,HeadShot_Damage) htp = Hitted_Part dmg = Normal_Damage
dhm = GetHumanoid(htp) if dhm == nil then return end
if htp.Parent.className == "Hat" or htp.Name == "Head" then dmg = HeadShot_Damage end
if dhm then h_team = InspectTeam(dhm) if check_aggressive(player.TeamColor,h_team) then
local tag = Instance.new("ObjectValue") tag.Name = "creator" tag.Value = player debris:AddItem(tag, 3) tag.Parent = targethumanoid
getps = GetPosFromHum(dhm) if getps ~= Vector3.new() then psval = Instance.new("IntValue",tag) psval.Name = "Distance" psval.Value = math.floor((getps-MyPos()).magnitude) end
tag.Parent = dhm wait(0.1) dhm:TakeDamage(dmg) wait(2) local tag = Instance.new("ObjectValue") tag.Name = "creator" tag.Value = player debris:AddItem(tag, 3) tag.Parent = targethumanoid delay(3) tag.Parent = nil end end end
function Run(mouse) if is_reloading then mouse.Icon = Reload_icon return end mouse.Icon = Normal_icon local hit = mouse.Target if (hit == nil) then return end h = GetHumanoid(hit) if h ~= nil then torso = hit.Parent.Torso if torso ~= nil then if h.Health > 0 then if check_aggressive(player.TeamColor,InspectTeam(h)) then mouse.Icon = Enemy_icon else mouse.Icon = Friend_icon end end end end end
function ShakeCam() cam = game.Workspace.CurrentCamera function RandVector() return Vector3.new(math.random(-100,100)/40000,math.random(-100,-20)/20000,math.random(-100,100)/40000) end function Mult(vct,ml) return Vector3.new(vct.x*ml,vct.y*ml,vct.z*ml) end local tvc = RandVector() local tam = math.random(3,3) for i = 1,tam do cam.CoordinateFrame = cam.CoordinateFrame * CFrame.new(Mult(tvc,math.sin(math.rad((90/tam)*i)))) wait() end for i = tam,1,-1 do cam.CoordinateFrame = cam.CoordinateFrame * CFrame.new(Mult(-tvc,math.sin(math.rad((90/tam)*i)))) wait() end end
function on(mouse) fireon = false mouse.Button1Down:connect(function() fireon = true if not Automatic then shot() end end) mouse.Button1Up:connect(function() fireon = false end)
function onKeyDown(key) if (key~=nil) then key = key:lower() if key == "r" and the_clip < Clip_Size then if is_reloading then return end ammtxt.Text = "Reloading" is_reloading = true if reload_sound ~= nil then reload_sound:play() end wait(Reload_Speed) the_clip = Clip_Size is_reloading = false ammtxt.Text = the_clip .. " / " .. Clip_Size end end end mouse.KeyDown:connect(onKeyDown)
function shot() if char.Humanoid.Health <= 0 then return end if is_reloading then return end if tick() - last_shot < Fire_Speed and the_clip > 0 then return end if the_clip <= 0 then ammtxt.Text = "./INF" is_reloading = true if reload_sound ~= nil then reload_sound:play() end wait(Reload_Speed) the_clip = Clip_Size is_reloading = false ammtxt.Text = the_clip .. " / " .. Clip_Size else script.Parent.Recoil.Value = 6 last_shot = tick() the_clip = the_clip - 1 ammtxt.Text = the_clip .. " / " .. Clip_Size if fire_sound ~= nil then fire_sound:play() end if CheckIfZoomed() then PreFire(GetCamAim()) --mouse.Hit.p) else PreFire(mouse.Hit.p) end end end
the_gui.Parent = player.PlayerGui
while true do wait() Run(mouse) end end
script.Parent.Unequipped:connect(function() fireon = false the_gui.Parent = nil end) script.Parent.Equipped:connect(on)
function raycast(orig33,hitpos33,ignorelist33) --Fire position, Aim Position, Ignored items. local origin, frame, ray; frame = CFrame.new(orig33, hitpos33) ray = Ray.new(frame.p, frame.lookVector * 10) local part, hitpos = Workspace:FindPartOnRay(ray, ignorelist33) if (part) then if part:IsDescendantOf(char) then return nil, Vector3.new() end if part:findFirstChild("Bouncy") ~= nil then if part:findFirstChild("Bouncy").ClassName == "BoolValue" then if part:findFirstChild("Bouncy").Value then return Tool.Handle, Vector3.new() end end end if part:findFirstChild("Ignore") ~= nil then if part:findFirstChild("Ignore").ClassName == "BoolValue" then if part:findFirstChild("Ignore").Value then return nil, Vector3.new() end end end if part:findFirstChild("Damage") ~= nil then local thp = part:findFirstChild("Damage"):findFirstChild("health") local ttm = part:findFirstChild("Damage"):findFirstChild("team") if part.Damage.ClassName == "BoolValue" and thp ~= nil and ttm ~= nil then if part:findFirstChild("Damage").Value and check_aggressive(ttm.Value,player.TeamColor) then if Damage > part.Damage:findFirstChild("health").Value then part.Damage:findFirstChild("health").Value = 0 local tag = Instance.new("ObjectValue") tag.Name = "creator" tag.Value = player debris:AddItem(tag, 3) tag.Parent = targethumanoid else part.Damage:findFirstChild("health").Value = part.Damage:findFirstChild("health").Value - Damage end return part, hitpos end end end return part, hitpos else return nil, Vector3.new() end end
chk = Instance.new("IntValue") chk.Value = 0 fire_at = Vector3.new()
function PreFire(pss) for i = 1,Shots_Per_Bullet do fire_at = pss chk.Value = chk.Value + 1 end end
chk.Changed:connect(function() Fire(fire_at) end) chk.Changed:connect(ShakeCam)
function Fire(aim) local shooting_ray = CFrame.new((Tool.Handle.CFrame * CFrame.new(Shoot_From)).p,aim) local Gen_Inacc = Vector3.new(math.random(-Inaccuracy*100,Inaccuracy*100)/100,math.random(-Inaccuracy*100,Inaccuracy*100)/100,math.random(-Inaccuracy*100,Inaccuracy*100)/100) local shooting_ray2 = CFrame.new(shooting_ray.p,(shooting_ray * CFrame.new(0,0,-100)).p + Gen_Inacc) local lazer_start = shooting_ray2 * CFrame.Angles(math.pi / 2, 0, 0) ignoreit = Shots local i,a,m,hitted local p = shell:clone() p.Parent = Shots p.CFrame = lazer_start hitted = nil local cnt = 0 for i = 1,Distance do p.CFrame = lazer_start * CFrame.Angles(bullet_spin.x*math.pi,bullet_spin.y*math.pi,bullet_spin.z*math.pi) count_start = (lazer_start * CFrame.new(0,-0.8,0)).p count_end = (lazer_start * CFrame.new(0,-1,0)).p hitted, hpos = raycast(count_start,count_end,ignoreit) lazer_start = lazer_start * CFrame.new(0,-1,0) if i*Bullet_Speed > Distance_With_No_Gravity then if (lazer_start * CFrame.new(0,-1,0)).p.y - lazer_start.p.y > -0.85 then lazer_start = lazer_start * CFrame.Angles(math.rad(-0.05*Bullet_Gravity), 0, 0) end end if (hitted) then break end cnt = cnt + 1 if cnt == Bullet_Speed then cnt = 0 wait() end end
p:remove()
if hitted then if not hitted:IsDescendantOf(char) then GiveDamage(hitted,Damage,Head_Damage) end end end
if Automatic then while true do wait() if fireon then shot() end end end
End of script..
The tag script:
local tag = Instance.new("ObjectValue") tag.Name = "creator" tag.Value = player debris:AddItem(tag, 3) tag.Parent = targethumanoid
End script
Locals:
local debris = game:GetService("Debris") local tuple = {...} local playerhit = tuple[3] local targethumanoid = playerhit.Parent:FindFirstChild("Humanoid")
End Locals |
|
|
| Report Abuse |
|
|
| 15 Nov 2014 07:52 PM |
way too long you have to do some digging and find the place where the problem starts to happen
sorry but nobodys going to actually read all of this :\ |
|
|
| Report Abuse |
|