bibo5o
|
  |
| Joined: 17 Jan 2009 |
| Total Posts: 414 |
|
|
| 15 Mar 2015 05:21 PM |
--So, this script with it's current settings *should* shoot 10 shots every click. Everything else works fine, but it very rarely ever shoots 10 shots. Can anyone see any problem with it?
--Settings damage = 6 mode = 0 --0 non-auto, 1 auto reload = .625 pierces = 1 --1 cannot go through bricks, 2 can go through 1 brick, 3 through 2 etc maxClip = 6 BulletsPerShot = 10 clipReload = 0.66 accuracy = 50 knockback1 = 0.6 knockback2 = 1 reloadType = "2" maxAmmo = 32 --name = "Non1"
--Variables
Reloading = 0 local tool = script.Parent local user clip = script:findFirstChild("Clip") while clip == nil do clip = script:findFirstChild("Clip") wait() end
--Script
function untag(tag, f) wait(1) f:Destroy() tag:Destroy() end
function Fiyah(mouse) Fire(mouse) end
function Hit (i, hit, velocity) --if hit ~= nil then print(hit.Name) end local distance = i - 50 if distance > 50 then distance = 50 end --do damage to any humanoids hit if hit ~= nil and hit.Parent:IsA("Hat") then hit = hit.Parent end local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") if humanoid then local dmg = damage if game.Workspace.Settings.Settings.RandomSpread.Value == 1 and game.Players:GetPlayerFromCharacter(user).Critical.Value ~= 2 then dmg = dmg * math.random(0.9, 1.1) end if game.Workspace.Settings.Settings.DamageRamp.Value == 1 and game.Players:GetPlayerFromCharacter(user).Critical.Value ~= 2 then dmg = dmg*(1-(distance/100)) end humanoid:TakeDamage(dmg) if game.Players:GetPlayerFromCharacter(user).Critical.Value == 1 then humanoid:TakeDamage(dmg*0.33) elseif game.Players:GetPlayerFromCharacter(user).Critical.Value == 2 then humanoid:TakeDamage(dmg*2) end local cl = script.BillboardGui:Clone() if damage > 0 then cl.TextLabel.Text = dmg end if game.Players:GetPlayerFromCharacter(user).Critical.Value == 1 then cl.TextLabel.Text = dmg*1.33 cl.TextLabel.TextColor3 = Color3.new(1,215/255,53/255) end if game.Players:GetPlayerFromCharacter(user).Critical.Value == 2 then cl.TextLabel.Text = dmg*3 cl.TextLabel.TextColor3 = Color3.new(11/255,15/255,1) end cl.TextLabel.Text = math.ceil(cl.TextLabel.Text) cl.Adornee = hit.Parent.Head local v = Instance.new("StringValue") v.Value = hit.Parent.Parent.Name v.Parent = cl cl.Parent = game.Players:GetPlayerFromCharacter(user).PlayerGui.TextWait cl.Script.Disabled = false local tag = Instance.new("ObjectValue") tag.Name = "creator" tag.Value = game.Players:FindFirstChild(user.Name) tag.Parent = hit.Parent local f = Instance.new("BodyVelocity") f.velocity = Vector3.new(velocity.X * knockback1,knockback2,velocity.Z * knockback1) f.maxForce = Vector3.new(6000,6000,6000) f.Parent = hit.Parent.Torso local sc = script.Script:Clone() sc.Value.Value = f sc.Parent = tag end end
function Fire(mouse) local position = tool.Hole.CFrame.p local x = math.random(-accuracy,accuracy) * tool.Handle.CFrame.lookVector.X local y = math.random(-accuracy,accuracy) local z = math.random(-accuracy,accuracy) * tool.Handle.CFrame.lookVector.Z --make and do a hit test along the ray local velocity = tool.Handle.CFrame.lookVector * -20 local position2 = position local ray = Ray.new(position, ((mouse.Hit.p - tool.Handle.CFrame.p).unit)*300 + Vector3.new(x,y,z)) local hit, position = game.Workspace:FindPartOnRay(ray, user) if hit ~= nil then local i = math.ceil((hit.Position - position2).magnitude) Hit(i, hit, velocity) end local p = Instance.new("Part") p.BrickColor = BrickColor.new("New Yeller") p.Transparency = 0.5 p.TopSurface = Enum.SurfaceType.Smooth p.BottomSurface = Enum.SurfaceType.Smooth p.formFactor = Enum.FormFactor.Custom p.Size = Vector3.new(0.2, 0.2, (position - position2).magnitude) p.CFrame = CFrame.new(position, position2) * CFrame.new(0, 0, -((position - position2).magnitude)/2) p.CanCollide = false p.Anchored = true p.Parent = workspace game.Debris:AddItem(p, 0.1) --[[fire = script.Parent.Fire:Clone() fire.Parent = tool fire:Destroy()]] end
tool.Equipped:connect(function(mouse) debounce = false user = tool.Parent game.Players:GetPlayerFromCharacter(user).PlayerGui.Ammo.Frame.TextLabel.Text = script.Clip.Value.." / "..script.Ammo.Value mouse.KeyDown:connect(function(key) if key == "r" then if reloadType == "full" then Reloading = 1 wait(clipReload) if script.Ammo.Value > maxClip - clip.Value then script.Ammo.Value = script.Ammo.Value - (maxClip - clip.Value) clip.Value = maxClip else clip.Value = script.Ammo.Value + clip.Value script.Ammo.Value = 0 end else Reloading = 2 while script.Ammo.Value > 1 and clip.Value < maxClip do wait(clipReload) if Reloading == 0 or script.Ammo.Value == 0 or clip.Value == maxClip then break end if script.Ammo.Value > 0 and clip.Value < maxClip then script.Ammo.Value = script.Ammo.Value - 1 clip.Value = clip.Value + 1 end game.Players:GetPlayerFromCharacter(user).PlayerGui.Ammo.Frame.TextLabel.Text = script.Clip.Value.." / "..script.Ammo.Value end end Reloading = 0 game.Players:GetPlayerFromCharacter(user).PlayerGui.Ammo.Frame.TextLabel.Text = script.Clip.Value.." / "..script.Ammo.Value end end) tool.Unequipped:connect(function() game.Players:GetPlayerFromCharacter(user).PlayerGui.Ammo.Frame.TextLabel.Text = " / " end)
if mode == 1 then mouse.Button1Up:connect(function() down = 0 end) mouse.Button1Down:connect(function() down = 1 end) tool.Unequipped:connect(function() down = -1 end) down = 0 while true do if user.Humanoid.Health == 0 then break end while down == 1 do if user.Humanoid.Health == 0 or clip.Value == 0 or Reloading == 1 then break end for i=1, BulletsPerShot do Fiyah(mouse) --math.randomseed(math.random(0.01,10.00)) end clip.Value = clip.Value - 1 game.Players:GetPlayerFromCharacter(user).PlayerGui.Ammo.Frame.TextLabel.Text = script.Clip.Value.." / "..script.Ammo.Value if clip.Value == 0 then if reloadType == "full" then wait(clipReload) if script.Ammo.Value > maxClip - clip.Value then script.Ammo.Value = script.Ammo.Value - (maxClip - clip.Value) clip.Value = maxClip else clip.Value = script.Ammo.Value + clip.Value script.Ammo.Value = 0 end else Reloading = 2 while script.Ammo.Value > 1 and clip.Value < maxClip do wait(clipReload) if Reloading == 0 or script.Ammo.Value == 0 or clip.Value == maxClip then break end if script.Ammo.Value > 0 and clip.Value < maxClip then script.Ammo.Value = script.Ammo.Value - 1 clip.Value = clip.Value + 1 end game.Players:GetPlayerFromCharacter(user).PlayerGui.Ammo.Frame.TextLabel.Text = script.Clip.Value.." / "..script.Ammo.Value end end game.Players:GetPlayerFromCharacter(user).PlayerGui.Ammo.Frame.TextLabel.Text = script.Clip.Value.." / "..script.Ammo.Value end --script.Parent.Name = name..": "..clip wait(reload) if Reloading == 1 then while clip.Value ~= maxClip do wait() end end end wait(reload) if down == -1 then break end end else mouse.Button1Down:connect(function() if Reloading == 2 then debounce = false Reloading = 0 end if debounce == true or user.Humanoid.Health == 0 or clip.Value == 0 or Reloading == 1 then return end debounce = true for i=1, BulletsPerShot do Fiyah(mouse) --math.randomseed(math.random(0.01,10.00)) end clip.Value = clip.Value - 1 game.Players:GetPlayerFromCharacter(user).PlayerGui.Ammo.Frame.TextLabel.Text = script.Clip.Value.." / "..script.Ammo.Value wait() if clip.Value == 0 then if reloadType == "full" then game.Players:GetPlayerFromCharacter(user).PlayerGui.Ammo.Frame.TextLabel.Text = script.Clip.Value.." / "..script.Ammo.Value wait(clipReload) if script.Ammo.Value > maxClip - clip.Value then script.Ammo.Value = script.Ammo.Value - (maxClip - clip.Value) clip.Value = maxClip else clip.Value = script.Ammo.Value + clip.Value script.Ammo.Value = 0 end else Reloading = 2 while script.Ammo.Value > 1 and clip.Value < maxClip do wait(clipReload) if Reloading == 0 or script.Ammo.Value == 0 or clip.Value == maxClip then break end if script.Ammo.Value > 0 and clip.Value < maxClip then script.Ammo.Value = script.Ammo.Value - 1 clip.Value = clip.Value + 1 end game.Players:GetPlayerFromCharacter(user).PlayerGui.Ammo.Frame.TextLabel.Text = script.Clip.Value.." / "..script.Ammo.Value end end game.Players:GetPlayerFromCharacter(user).PlayerGui.Ammo.Frame.TextLabel.Text = script.Clip.Value.." / "..script.Ammo.Value end --script.Parent.Name = name..": "..clip wait(reload) if Reloading == 1 then while clip.Value ~= maxClip do wait() end end debounce = false end) end end)
--[[while wait(.1) do math.randomseed(math.random(0.01,10.00)) end]] |
|
|
| Report Abuse |
|
|
| |
|
mrfergie
|
  |
| Joined: 25 Mar 2010 |
| Total Posts: 522 |
|
| |
|
IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
|
| 15 Mar 2015 05:26 PM |
| Make your own script and we'll help you. |
|
|
| Report Abuse |
|
|
|
| 15 Mar 2015 05:28 PM |
Make your own script and we'll help you.[(2 or 3)]
This script is very terribly scripted anyway. |
|
|
| Report Abuse |
|
|
|
| 15 Mar 2015 06:18 PM |
for i = 1, 10 do --make the Bullet and do stuff with it end
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
bibo5o
|
  |
| Joined: 17 Jan 2009 |
| Total Posts: 414 |
|
|
| 16 Mar 2015 12:06 PM |
@loliderp I did make it, ;3
@MrJoeyJoey Thank you, I do try my best to make it inefficient.
@Kapitanovas That's what it does
for i=1, BulletsPerShot do Fiyah(mouse) --math.randomseed(math.random(0.01,10.00)) end
I've tested in studio and it IS firing 10 shots, but I for sure cannot see 10 of them, and not 10 of them are hitting, even at point blank. There seems to be a large amount of them grouping up in a particular spot, so I'm just going to mess around with it. Thank you Kap for trying to be helpful, rest of ya, not appreciated. |
|
|
| Report Abuse |
|
|
|
| 16 Mar 2015 12:08 PM |
well... are u doin an Accuracy/Spread kinda thing? cos it might be too Big :/
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
bibo5o
|
  |
| Joined: 17 Jan 2009 |
| Total Posts: 414 |
|
|
| 16 Mar 2015 12:12 PM |
| I am, yes. I think the rays are hitting each other, so I'll just make them appear in the workspace a little bit delayed. Only thing is if they're hitting each other than you could potentially just fire a shot and other people couldn't fire through it, so I guess I'll have to make them go through the rays. |
|
|
| Report Abuse |
|
|
|
| 16 Mar 2015 12:15 PM |
yup... though u should try Projectile instead! it's AMAZING! I Scripted a Shotgun for a guy that made it and it looked sooo Cool! just like in Real Life u'd see all those Circly Bullets XD
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
bibo5o
|
  |
| Joined: 17 Jan 2009 |
| Total Posts: 414 |
|
|
| 16 Mar 2015 12:40 PM |
I would try a projectile, but the idea is I'm trying to make TF2 on roblox, and the shoguns on TF2 are hitscan, soo, I am limited in that respect, ;c.
FindPartOnRayWithIgnoreList() is my saviour, :D. It was definitely rays hitting rays. |
|
|
| Report Abuse |
|
|
|
| 16 Mar 2015 12:42 PM |
oh... well if ya feel like Rays are ur way then I can't change ur Mind :P Good Luck on ur Shotgun ;)
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|