So I learned filtering enabled but I just touched the bare bones of it. I know how to use RemoteEvents and I tried to convert my script to filtering.
I tried to send the server where the player clicked but it wouldn't work. It would give me errors that didn't make sense. I'm not sure else how I could convert it. Can someone tell me how should I do it?
I don't need a full on script but rather an explanation.
I think I only need to show the Activation tool part of the script since that's where the raycasting happens. If you need me to show more you can leave down a comment and I'll show it.
If you like here is my script:
local function ToolActivate()
if Ammo > 1 and Player.Character.Humanoid.Health > 1 and GunState.Firing then
InputBeganEvent:Disconnect()
repeat
Settings.GunFire.Enabled = true
Settings.GunLight.Enabled = true
-- RemoteEvent:FireServer() -- gun values here
Ammo = Ammo - 1
local ray = Ray.new(Tool.Handle.CFrame.p, (Mouse.Hit.p - Tool.Handle.CFrame.p).unit * 300)
local part, position = game.Workspace:FindPartOnRay(ray, Player.Character, false, true)
local beam = Instance.new("Part", workspace) --comestic
beam.BrickColor = BrickColor.new("New Yeller")
beam.FormFactor = "Custom"
beam.Material = "Neon" --comestic
beam.Transparency = 0.25
beam.Anchored = true --misc
beam.Locked = true
beam.CanCollide = false
--preparation
local distance = (Tool.Handle.CFrame.p - position).magnitude
beam.Size = Vector3.new(0.3, 0.3, distance) --finialization
beam.CFrame = CFrame.new(Tool.Handle.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
game:GetService("Debris"):AddItem(beam, 0.06)
Sounds.GunSound:Play()
if part then --checking if ray hit a part
local humanoid = part.Parent:FindFirstChild("Humanoid")
if not humanoid then
humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
end
if humanoid then
humanoid:TakeDamage(10)
humanoid.WalkSpeed = humanoid.WalkSpeed / 2
end
end
wait(Settings.FireRate)
Settings.GunFire.Enabled = false
Settings.GunLight.Enabled = false
until not GunState.Firing or Ammo == 0
end
InputBeganEvent = UserInputService.InputBegan:Connect(InputBegan)
if Ammo == 0 then
ReloadGun()
GunState.Firing = false
end
end
--Settings is just a table that has editable stats in it.
--GunState is just a table that is determining the state of the gun, e.g reloading, firing.
Edit: Here is my lines that are giving the error of "p is not a valid member of player". The error is on where it says local ray
local function FireServer(MouseHit, ToolHandleCFrame, Player, Damage)
local ray = Ray.new(ToolHandleCFrame.p, (MouseHit.p - ToolHandleCFrame.p).unit * 300)
local part, position = game.Workspace:FindPartOnRay(ray, Player.Character, false, true)
--ToolHandleCFrame is just Tool.Handle.CFrame
--MouseHit is just Mouse.Hit
--Player is just the player who is firing the server
--Damage is just the gun's damage.
Thank you for reading

6 comments
I dont think you activated the function bro xd
I'm surprised that you have 85 reputation with this type of question.
I activated the function lol and I am new to this stuff, I’ve been scripting my game before the filter update game and it broke my scripts.
the "p is not a valid member of player" is caused by you trying to get a property called "p" from a player object. Seeing as in the line where it errors you are trying to get p from ToolHandleCFrame and HouseHit, it means one of those is actually the player. Also, I see that all those are parameters, so perhaps try checking if you are passing them to the RemoteEvent:FireServer() function in the
same order
It fully worked! It is just only placing the raycasting beam at a werid angle.