local rate = 1/30
local tool = script.Parent
local event = tool:WaitForChild("RemoteEvent")
local handle = tool:WaitForChild("Handle")
local debris = game:GetService("Debris")
local windvec = Vector3.new(2, 1, 1)
local barreloffset = Vector3.new(0, 0, -1.5)
function drawbeam(beamstart, beamend, color, fadedelay)
local dist = (beamstart - beamend).magnitude
local laser = Instance.new("Part")
laser.name = "Effect"
laser.Anchored = true
laser.CanCollide = false
laser.Shape = "Block"
laser.FormFactor = "Custom"
laser.Size = Vector3.new(.2,.2,.2)
laser.Transparency = .5
laser.Material = "Plastic"
laser.Locked = true
laser.TopSurface = "Smooth"
laser.BottomSurface = "Smooth"
laser.BrickColor = color
laser.CFrame = CFrame.new(beamend, beamstart) * CFrame.new(0, 0, -dist( 2) * CFrame.Angles(math.pi / 2, 0, 0))
local mesh = Instance.new("SpecialMesh")
mesh.Scale = Vector3.new(1, 5, 1)
mesh.Parent = laser
debris:AddItem(laser, fadedelay * 1)
laser.Parent = game.Workspace
local frames = math.floor(fadedelay / rate)
for frame = 1, frames do
wait(rate)
if laser then
local percent = frame / frames
laser.CFrame = laser.CFrame + (windvec * rate)
laser.Transperency = .5 + (percent * .5)
end
end
if laser then
laser:remove()
end
end
event.OnServerEvent:connect(function(player, ...)
local tuple = {...}
if tuple[1] == "Fire" then
local endpos = tuple[2]
local hit = tuple[3]
local fakestartpos = (handle.CFrame * CFrame.new(barreloffset)).p
Spawn(function()
drawbeam(fakestartpos, endpos, BrickColor.new("Institutional White"), .25)
end)
if hit and hit.Parent then
local targethumanoid = hit.Parent:FindFirstChild("Humanoid")
local targettorso = hit.Parent:FindFirstChild("Torso")
if targethumanoid and targettorso and targethumanoid.Health > 0 then
local net = Instance.new("TrussPart")
net.Name = "Net"
net.Size = Vector3.new(2, 6, 2)
net.Style = "AlternatingSupports"
net.Material = "Fabric"
net.BrickColor = BrickColor.new("Pastel brown")
net.CFrame = targettorso.CFrame
net.CanCollide = false
local weld = Instance.new("Weld")
weld.Part0 = targettorso
weld.Part1 = net
weld.C0 = CFrame.new(0 ,-.4 - (math.random() * .4) ,0) * CFrame.Angles(0, math.pi * 2 * math.random(), math.pi * .3 * (math.random(0,1) - .5))
weld.Parent = net
targethumanoid.WalkSpeed = 6
delay(5, function()
if net and targethumanoid and targethumanoid.Parent then
net:remove()
if not targethumanoid.Parent:FindFirstChild("Net") and targethumanoid.WalkSpeed < 16 then
targethumanoid.WalkSpeed = 16
end
end
end)
if targethumanoid.Parent:FindFirstChild("Net") then
delay(.5, function()
if targethumanoid then
if v and v.Name == "creator" then
v:remove()
end
local tag = Instance.new("ObjectValue")
tag.Name = "creator"
tag.Value = player
debris:AddItem(tag, 3)
tag.parent = targethumanoid
targethumanoid:TakeDamage(100)
end
end)
end
debris:AddItem(net, 6)
net.Parent = hit.Parent
end
end
end
end)
Why doesn't this script work?
1 answer
It looks like your trying to make the Net Gun in the tutorials, rewatch the video and redo the scripts. I figured out my error was in the LocalScript.
Edit: Also, if you test it on a server, when if you get an error when on the screen controlling the player its in the LocalScript most likely, and if its in the server window the error, its the normal Script/ServerScript that the error is in
3 comments
Well i already figured out that the LocalScript is working i'm 98% sure it is but this script isn't, also i can't test my games in studio i have to actully play the game to test my stuff, whenever i try to test in studio it says "Core Scripts won't load" something like that so i can't check the output at all.
In online mode, you can press F9 to open the developer console, which has the output.
Oh thanks.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Any output?