When I run the code locally it works well but when I run it on a server, it does not recognize the mouse. I am pretty new to filtering enabled and I need help. Side note: the damage does not work either.
Local script:
h = script.Parent.Handle
script.Parent.Activated:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer(h)
end)
Server script:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, handle)
local m = plr:GetMouse()
local b = Instance.new("Part",game.Workspace)
b.Shape = "Ball"
b.BrickColor = BrickColor.new("Really red")
b.Size = Vector3.new(1,1,1)
b.CFrame = CFrame.new(handle.Position, mouse.hit.p)
local v = Instance.new("BodyVelocity",b)
v.Velocity = b.CFrame.lookVector * 400
v.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
local d = game:GetService("Debris")
d:AddItem(b, 5)
b.Touched:connect(function(hit)
if hit ~= handle then
local h = hit.Parent:FindFirstChild("Humanoid")
if h then
if h.Parent.Name ~= plr.Name then
h:TakeDamage(10)
end
end
end
end)
end)

1 comment
Thank you very much. The extra tips have also helped me out a lot. I appreciate it.