I have the tool, that when you use it it shoots a laser beam.
The code is in a local script, which is in the tool. The tool is welded correctly and whatnot.
This only happens with online mode. Note -- I have filtering enabled on.
code:
local tool = script.Parent
local player = game:GetService("Players").LocalPlayer
tool.Equipped:connect(function(mouse)
mouse.Button1Down:connect(function()
local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300)
local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
local beam = Instance.new("Part", workspace)
beam.BrickColor = BrickColor.new("Bright red")
beam.FormFactor = "Custom"
beam.Material = "Neon"
beam.Transparency = 0.15
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false
local distance = (tool.Handle.CFrame.p - position).magnitude
beam.Size = Vector3.new(0.3,0.3,distance)
beam.CFrame = CFrame.new(tool.Handle.CFrame.p, position) * CFrame.new(0,0, -distance / 2)
game:GetService("Debris"):AddItem(beam, 1)
if part then
local humanoid = part.Parent:FindFirstChild("Humanoid")
if not humanoid then
humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
end
if humanoid then
humanoid:TakeDamage(25)
end
end
end)
end)
This is mainly just taken off the wiki when I was learning about rays and stuff.
What am I doing wrong?

2 comments
This script was not made for filtering enabled, which annoys me sometimes. Most of the wiki tutorials are not filtering enabled. So.. you'll have to do some work. I would say just make the script filtering enabled compatible, and see what happens.
This is a recent problem that was posted on the dev forum that roblox is working on with tools vanishing in test servers with filtering enabled on.