I am currently in the process of making an HP Wand. Unfortunately, it won't allow me to access the player mouse from the server.
Client
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:WaitForChild("AvadaKedavraEvent")
event:FireServer()
Server
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:WaitForChild("AvadaKedavraEvent")
local function avadakedavra()
local wand = game.StarterPack.Wand
local plr = game.Players.LocalPlayer
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:connect(function()
if _G.spell == 1 then
_G.spell = 0
local ray = Ray.new(
plr.Character.Head.CFrame.p,
(mouse.Hit.p - plr.Character.Head.CFrame.p).unit * 200)
local ignore = game.Players.LocalPlayer.Character
local part, position = workspace:FindPartOnRay(ray, plr.Character, false, true)
local hit, position, normal = workspace:FindPartOnRay(ray, ignore)
local beam = Instance.new("Part", workspace)
beam.BrickColor = BrickColor.new("Lime green")
beam.FormFactor = "Custom"
beam.Material = "Neon"
beam.Transparency = 0.5
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false
beam.Orientation = script.Parent.Handle.Orientation
beam.Shape = Enum.PartType.Block
beam.Size = Vector3.new(1,1,1)
local distance = (plr.Character.Head.CFrame.p - position).magnitude
print(distance)
beam.CFrame = CFrame.new(plr.Character.Head.CFrame.p,position)
local start = plr.Character.Head.CFrame
for i = 1, 10 do
beam.CFrame = start:lerp(CFrame.new(position),i/10)
wait()
end
if part then
local humanoid = part.Parent:FindFirstChild("Humanoid")
if not humanoid then
humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
end
if humanoid then
humanoid.Health = humanoid.Health - 110
end
beam:Destroy()
end
end
end)
end
event.OnServerEvent:Connect(avadakedavra)
ServerScriptService.Script:7: attempt to index field 'LocalPlayer' (a nil value)

4 comments
You may NOT use the mouse on the server
hol' up im'a right an answer
You can't call LocalPlayer in a regular script because the server has no local player.
^ yes