Kso
What im trying to do is get the position of mouse.hit in a ServerScript because my game is FilteringEnabled, however I have no idea how i'd do that without handling all of it in a localscript which doesent work. Ive seen people with Filtering games do stuff with the mouse before, so could someone give an example of how to do this?
EDIT: Used Perci1's code, and it works in Studio, but not in online + FE; it says that playerMouse (the variable i used in the serverscript to refer to the mouse) is nil whenever I shoot. Ill provide code if necessary.
EDIT2; Tried to set playerMouse to mouse.Hit.p; Threw a vector3 error.
The script
workspace.REgetmouse.OnServerEvent:connect(function(player, mouse)
playerMouse = mouse.Hit.p
end)
debounce = false
Debris = game:GetService('Debris')
function workspace.RFshooting.OnServerInvoke(player, tuple)
player.Character.Humanoid.shooting.Value = true
while player.Character.Humanoid.shooting.Value == true and wait() do
if not debounce and player and player.Character.Humanoid and player.Character.Humanoid.Health > 0 and player.Character.Torso and player.Character.Humanoid.bullets.Value > 0 then
debounce = true
local ammo = player.Character.Humanoid.bullets
ammo.Value = ammo.Value - 1
local spd = 225
local cooldown = 0.08 -- 0.08
local rng = 5
local dmg = 12
local bullet = Instance.new('Part', workspace)
bullet.Name = 'bullet'
bullet.CanCollide = false
bullet.FormFactor = Enum.FormFactor.Custom
bullet.Size = Vector3.new(0.3, 0.3, 5)
bullet.Transparency = 0
bullet.Position = player.Character.Torso.Position
bullet.Material = Enum.Material.Neon
bullet.BrickColor = BrickColor.Blue()
bullet.Transparency = 0.2
local light = Instance.new('SurfaceLight', bullet)
light.Color = Color3.new(0.35, 0.65, 1)
local direction = (playerMouse - player.Character.Torso.Position)
bullet.CFrame = CFrame.new(player.Character.Torso.Position, player.Character.Torso.Position + direction)
bullet.Velocity = bullet.CFrame.lookVector * spd
Debris:AddItem(bullet, rng)
local velocity = Instance.new('BodyForce', bullet)
velocity.force = Vector3.new(0, bullet.Size.X * bullet.Size.Y * bullet.Size.Z * 196.2, 0)
local particle = game.ReplicatedStorage.Laser.ParticleEmitter:Clone()
particle.Parent = bullet
local num = math.random(1, 2)
if num == 1 then
particle.Rotation = NumberRange.new(0, 0)
else
particle.Rotation = NumberRange.new(180, 180)
end
bullet.Touched:connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild('Humanoid') and hit.Parent ~= player.Character then
hit.Parent.Humanoid:TakeDamage(dmg)
bullet:Destroy()
elseif hit.Parent == player.Character then
elseif hit.Name ~= 'bullet' and hit.Name ~= 'aibullet' then
bullet:Destroy()
end
end)
wait(cooldown)
debounce = false
end
end
end

3 comments
When I added this to my firing script and adjusted the mouse variables accordingly, it threw an error on mouse.Hit.p saying that hit is not a valid member of Player.
Add a player argument before the mouse argument in the server script, so it looks like this: function(player,mouse)
I knwo what's your error Perci1, Its in the ServerScript the parametre is player, mouse and not only mouse if you want to know what go on wiki I don't want to explain e.e