Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to edit my gun gun script in order to make it won't kill my teammates?

Asked by 5 years ago

I'm trying to make a gun game, but my gun can kill my teammates. How can I edit this to avoid that? (Sorry if it looks really messy and really unoptimized, I'm really new to Roblox scripting.) Code:

001    local function createBullet(target)
002local bullet = tool.Bullet:Clone()
003table.insert(ignoreTable, bullet)
004bullet.Parent = workspace
005bullet.CFrame = CFrame.new(muzzle.CFrame.p, target)
006bullet.Trail.Enabled = true
007wait() -- so trail has time to load
008 
009bullet.Transparency = 0
010local missionAccomplished = false  
011 
012for i = 1, numSegments do
013    if not missionAccomplished then
014        local equation  = bullet.CFrame * CFrame.new(0, 0, -segmentLength) * CFrame.Angles(dropAngle, 0, 0)
015        local ray = Ray.new(bullet.Position, (equation.p - bullet.Position).unit * segmentLength)
View all 103 lines...

end

0
Really? Nobody is helping?? p2013125 -3 — 5y
0
4 hours and not even a response. What the heck??? p2013125 -3 — 5y
0
33 views and nobody is posting a response. Please, say something at least. p2013125 -3 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

I guess this should work :

001local function createBullet(target)
002local bullet = tool.Bullet:Clone()
003table.insert(ignoreTable, bullet)
004bullet.Parent = workspace
005bullet.CFrame = CFrame.new(muzzle.CFrame.p, target)
006bullet.Trail.Enabled = true
007wait() -- so trail has time to load
008 
009bullet.Transparency = 0
010local missionAccomplished = false  
011 
012for i = 1, numSegments do
013    if not missionAccomplished then
014        local equation  = bullet.CFrame * CFrame.new(0, 0, -segmentLength) * CFrame.Angles(dropAngle, 0, 0)
015        local ray = Ray.new(bullet.Position, (equation.p - bullet.Position).unit * segmentLength)
View all 111 lines...
0
Thanks, it worked really well! p2013125 -3 — 5y
Ad

Answer this question