generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Hey, I have this gun issue

Previous Thread :: Next Thread 
TheJKid is not online. TheJKid
Joined: 22 Oct 2009
Total Posts: 5202
19 Jan 2012 11:31 AM
Hey helpers.

I have a gun, here's the problem.

If you stick the gun in the wall it can shoot onwards at the part in front of it allowing you to hurt the player on the other side.

It's a laser gun.

Here's what I think is making it do it.
The gun works by checking to see if the laser hits a part, but it will not hit a part if it's ALREADY in a part.

Any suggestions or ideas on how I could fix this?

Thanks

P.S It's not to do with where the barrel is, I tried making it come from the handle, yet it still would not work.
Report Abuse
rangersmash is not online. rangersmash
Joined: 18 Nov 2009
Total Posts: 2891
19 Jan 2012 11:35 AM
[ Content Deleted ]
Report Abuse
TheJKid is not online. TheJKid
Joined: 22 Oct 2009
Total Posts: 5202
19 Jan 2012 11:42 AM
rangersmash, it does use raycast..
Report Abuse
ggfunny1234 is not online. ggfunny1234
Joined: 09 Jul 2010
Total Posts: 3432
19 Jan 2012 11:47 AM
Maybe you can check if the position of the part that it's touching is == to the position of the barrel/handle..?

Sorry if this doesn't help, I don't deal with guns too often. :P
Report Abuse
DragonFang1 is not online. DragonFang1
Joined: 02 Apr 2009
Total Posts: 1068
19 Jan 2012 01:09 PM
use Region3
Report Abuse
TheJKid is not online. TheJKid
Joined: 22 Oct 2009
Total Posts: 5202
19 Jan 2012 01:54 PM
@DragonFang

I've looked on the wiki and I have no idea how I'd use region3 in my script.
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Jan 2012 01:59 PM
Search Crazyman32's tutorials in his models he might of made a Tutorial script.

It's not easy being cheesy.
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Jan 2012 02:00 PM
*Search Crazyman32's tutorials in his models he might of made a Tutorial script.*
Should be
*Search in Crazyman32's tutorials in his models he might of made a Tutorial script.*

It's not easy being cheesy.
Report Abuse
TheJKid is not online. TheJKid
Joined: 22 Oct 2009
Total Posts: 5202
19 Jan 2012 02:00 PM
@bikerking

I don't need a tutorial, I just need to know how I can fix it.
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Jan 2012 02:02 PM
Oh, then don't mind me.

It's not easy being cheesy.
Report Abuse
TheJKid is not online. TheJKid
Joined: 22 Oct 2009
Total Posts: 5202
19 Jan 2012 02:12 PM
I've been trying to fix this for about 5 hours now ;(
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Jan 2012 02:16 PM
Show the script?

It's not easy being cheesy.
Report Abuse
TheJKid is not online. TheJKid
Joined: 22 Oct 2009
Total Posts: 5202
19 Jan 2012 02:22 PM
Ok here it is:

------------------Don't touch these:--------------------
wait(0.01)
MyMouse = nil
MyChar = nil
Point = nil
target = nil
Mdown = false
bullet = nil
TargetChar = nil
val = nil
Deb = false
reloading = false
TarNil = false
max = script.Parent.Max
ammo = script.Parent.Ammo
---------------------------------------------------------

--------------------------------You can edit these-------
Range = 200 -- How far away the target can be.
Barrel = script.Parent["FirePoint"] -- Where the lazer comes from
LazerSize = 0.05 --- Thickness of Lazer. 0.25 is a standerd size.
Damage = 7
HeadDamage = 14
spread = 1
maxspread = 2
Chance = 2 ----Chance of having a direct hit. Lower = More Chance Higher = Less chance
ReloadTime = 0.4
DelayTime = 0.01
rapid = true
---------------------------------------------------------

---------Crusor Icons-------
NormalIcn = "http://www.roblox.com/asset/?id=68560654" -----Normal Crusor
TargetIcn = "http://www.roblox.com/asset/?id=68560669" -----When a person is highlighted

----------------------------

function holdshoot()
while Mdown do
wait(0)
shoot()
end
end

function down()
Mdown = true
holdshoot()
end

function up()
Mdown = false
end


function TK(Ppa)
if Ppa.Parent ~= nil then
if game.Players:GetPlayerFromCharacter(Ppa.Parent) ~= nil then
tkguy = game.Players:GetPlayerFromCharacter(Ppa.Parent)
if tkguy.TeamColor == MyPlayer.TeamColor then
return true
else
return false
end
else
return false
end
else
return false
end

end

function PlaySound(soundname)
if script.Parent:FindFirstChild(soundname) ~= nil then
TheSound = script.Parent:FindFirstChild(soundname)
TheSound:Play()
end
end

function Icon(TxtId)
if MyMouse ~= nil then
MyMouse.Icon = TxtId
end
end

function GetChar()
if script.Parent.Parent:IsA("Model") then
return script.Parent.Parent
elseif script.Parent.Parent.Parent:IsA("Player") then
return script.Parent.Parent.Parent.Character
end
end

function tag(humanoid)
if humanoid ~= nil then
val = Instance.new("ObjectValue", humanoid)
val.Name = "Creator"
val.Value = game.Players:GetPlayerFromCharacter(MyChar)
end
end

function untag()
if val ~= nil then
val:Remove()
end
end


function MakePoint()
Point = Instance.new("Part")
safe = Instance.new("BoolValue", Point)
safe.Name = "GunSafe9445"
Point.Anchored = true
Point.Locked = true
Point.CanCollide = false
Point.Transparency = 1
Point.FormFactor = Enum.FormFactor.Custom
Point.Size = Vector3.new(0.1, 0.1, 0.1)
Point.CFrame = MyMouse.Hit
Point.Parent = MyChar
end

function dist(pos1, pos2)
fdist = (pos1 - pos2).magnitude
return fdist
end

function shoot()

if Deb == false then
if ammo.Value >0 then
if reloading == false then
TargetChar = nil
if MyMouse.Target ~= nil then
if TK(MyMouse.Target) == false then
if Point ~= nil then

Point:Remove()
end
if bullet ~= nil then
bullet:Remove()
end
target = MyMouse.Target
if target ~= nil then
MyChar = GetChar()
MakePoint()
if dist(Barrel.Position, Point.Position) < Range then
Dis = dist(Barrel.Position, Point.Position)

TS = spread * Dis
if TS >maxspread then
TS = maxspread
end

a = Barrel.Position
b = Point.Position

ran2 = math.random(1, Chance)
if ran2 == 1 then
pos = Vector3.new(b.X, b.Y, b.Z)
else
ran = math.random(1, 4)
if ran == 1 then
pos = Vector3.new(b.X, b.Y, b.Z +TS)
elseif ran == 2 then
pos = Vector3.new(b.X, b.Y, b.Z -TS)
elseif ran == 3 then
pos = Vector3.new(b.X +TS, b.Y, b.Z)
elseif ran == 4 then
pos = Vector3.new(b.X -TS, b.Y, b.Z)
end
end

Point.CFrame = CFrame.new(pos)

local Ray = Ray.new(a,(pos-a).Unit*900)
local Hit, positionz = game.Workspace:FindPartOnRay(Ray,MyChar)
if Hit == nil then
else
if Hit.Parent == target.Parent or Hit.Parent.Parent == target.Parent.Parent then
ammo.Value = ammo.Value -1
print("Yes")
Deb = true
print(target:GetFullName())

if target:FindFirstChild("GunSafe9445") == nil then
if target.Parent:IsA("Hat") then
if target.Parent.Parent:IsA("Model") then
if target.Parent.Parent:FindFirstChild("Humanoid") ~= nil then
TargetChar = target.Parent.Parent
end
end
elseif target.Parent:IsA("Model") then
if target.Parent:FindFirstChild("Humanoid") ~= nil then
TargetChar = target.Parent
end
elseif target.Parent:IsA("Tool") then
if target.Parent.Parent:IsA("Model") then
if target.Parent.Parent:FindFirstChild("Humanoid") ~= nil then
TargetChar = target.Parent.Parent
end
end
end
end

if TargetChar ~= nil then
PlaySound("fire2")
hum = TargetChar:FindFirstChild("Humanoid")
tag(hum)
if target.Name == "Head" then
hum.Health = hum.Health - HeadDamage
else
hum.Health = hum.Health - Damage
end
else
PlaySound("fire")
end

print(target:GetFullName())
Dis = dist(Barrel.Position, Point.Position)
bullet = Instance.new("Part", MyChar)
bullet.Anchored = true
bullet.CanCollide = false
bullet.Transparency = 0
bullet.Locked = true
bullet.BrickColor = BrickColor.new("Really red")
bullet.FormFactor = Enum.FormFactor.Custom
bullet.Size = Vector3.new(LazerSize, LazerSize, (Barrel.Position-positionz).magnitude)
bullet.CFrame = CFrame.new(Barrel.Position, Point.Position)*CFrame.new(0, 0, -((Barrel.Position-positionz).magnitude)/2)
safe = Instance.new("BoolValue", bullet)
safe.Name = "GunSafe9445"
wait(0.1)
untag()
if Point ~= nil then
Point:Remove()
end
if bullet ~= nil then
bullet:Remove()
end
wait(DelayTime)
Deb = false
else
ammo.Value = ammo.Value -1
print(positionz)
PlaySound("fire")
Dis = dist(Barrel.Position, Point.Position)
bullet = Instance.new("Part", MyChar)
bullet.Anchored = true
bullet.CanCollide = false
bullet.Transparency = 0
bullet.Locked = true
bullet.BrickColor = BrickColor.new("Really red")
bullet.FormFactor = Enum.FormFactor.Custom
bullet.Size = Vector3.new(LazerSize, LazerSize, Dis)
bullet.CFrame = CFrame.new(Barrel.Position, Point.Position)*CFrame.new(0, 0, -Dis/2)
safe = Instance.new("BoolValue", bullet)
safe.Name = "GunSafe9445"
wait(0.1)
untag()
if Point ~= nil then
Point:Remove()
end
if bullet ~= nil then
bullet:Remove()
end
wait(DelayTime)
Deb = false
end
end
end
end
end
end
end
end
end
end

function Highlight()
if Deb == false then
if reloading == false then
TarNil = true
if MyMouse.Target ~= nil then
target = MyMouse.Target
if target:FindFirstChild("GunSafe9445") == nil then
if target.Parent:IsA("Hat") then
if target.Parent.Parent:IsA("Model") then
if target.Parent.Parent:FindFirstChild("Humanoid") ~= nil then
TarNil = false
end
end
elseif target.Parent:IsA("Model") then
if target.Parent:FindFirstChild("Humanoid") ~= nil then
TarNil = false
end
elseif target.Parent:IsA("Tool") then
if target.Parent.Parent:IsA("Model") then
if target.Parent.Parent:FindFirstChild("Humanoid") ~= nil then
TarNil = false
end
end
end
end
end
end

if TarNil == false then
Icon(TargetIcn) ---------Target crusor( when highlighting a person )
elseif TarNil == true then
Icon(NormalIcn) ----------Normal crusor
end

end
end

function reload(key)
if Deb == false then
if Reloading == false then

if key == "R" or key == "r" then
if ammo.Value < max.Value then
Reloading = true
PlaySound("rsound")
script.Parent["rload gui"].r.Value = true
while ammo.Value < max.Value and Deb == false do
print("1 ok")
Reloading = true
print("A ok")
print("B ok")
ammo.Value = ammo.Value +1
print("c ok")
if ammo.Value == max.Value then
print("done")

break
end
wait(ReloadTime)

end
Reloading = false
end
end

end
end

end

function select(mouse)
if mouse ~= nil then
TargetChar = nil
if Point ~= nil then
Point:Remove()
end
if bullet ~= nil then
bullet:Remove()
end
Reloading = false
Mdown = false
MyMouse = mouse
Icon(NormalIcn) ------ Normal crusor
if rapid == true then
MyMouse.Button1Down:connect(down)
MyMouse.Button1Up:connect(up)
elseif rapid == false then
MyMouse.Button1Down:connect(shoot)
end
MyMouse.KeyDown:connect(reload)
MyMouse.Move:connect(Highlight)
end
end

function deselect()
if mouse ~= nil then
TargetChar = nil
end
if Point ~= nil then
Point:Remove()
end
if bullet ~= nil then
bullet:Remove()
end
end

script.Parent.Unequipped:connect(deselect)
script.Parent.Equipped:connect(select)
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Jan 2012 02:27 PM
Wow that's a long script, I that was a mistake on asking to post.

It's not easy being cheesy.
Report Abuse
TheJKid is not online. TheJKid
Joined: 22 Oct 2009
Total Posts: 5202
19 Jan 2012 02:29 PM
@biker

Yeah it's very long :| Me and my brother spent ages on it. Now we're sstuck on this..
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Jan 2012 02:30 PM
Brb, i'm going to to if I can edit it.

It's not easy being cheesy.
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Jan 2012 02:33 PM
Any output?

It's not easy being cheesy.
Report Abuse
litozinnamon is not online. litozinnamon
Joined: 21 Dec 2009
Total Posts: 891
19 Jan 2012 02:35 PM
There is no error, so no output
Report Abuse
bikerking200 is not online. bikerking200
Joined: 11 Mar 2010
Total Posts: 5047
19 Jan 2012 02:36 PM
oh, Then I don't think I can help, I would love to help but it's to advance for me.

It's not easy being cheesy.
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
19 Jan 2012 02:37 PM
y u no check if touching brick?

-_-

~Flurite
Report Abuse
litozinnamon is not online. litozinnamon
Joined: 21 Dec 2009
Total Posts: 891
19 Jan 2012 02:40 PM
You could try changing the Barrel.Position to the Head.Position of the player
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
19 Jan 2012 02:50 PM
NO.

barrel = gun.Barrel

barrel.Touched:connect(function(touchingpart)
return touchingPart.Name == "Wall"
end)

~Flurite
Report Abuse
iZ0mGeD is not online. iZ0mGeD
Joined: 10 Jun 2011
Total Posts: 128
20 Jan 2012 08:08 AM
O.o
Report Abuse
ikoviron is not online. ikoviron
Joined: 21 Feb 2010
Total Posts: 226
20 Jan 2012 10:06 AM
Here is what I think is the problem, when you use the Instance.new("Part") on the following line's you made it CanCollide = False meaning the bullet or part can go through bricks, if you are going to do that you should add a Function inside the script saying if the brick hits another Part it will be deleted.
Report Abuse
TheJKidALT is not online. TheJKidALT
Joined: 12 Nov 2010
Total Posts: 48
20 Jan 2012 10:09 AM
I've fixxed the wall-shooting issue, now it's just my other "wall-shoot" issue where you stick the gun in the wall a bit and you can shoot through, even if the wall is 100x100
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image