As a side project in ROBLOX, I am making an HP wand. However, it won’t work. It just won’t work. There are no errors. It won’t create the spell.
Server:
local RepStorage = game:GetService("ReplicatedStorage")
local Event = RepStorage:WaitForChild("AvadaKedavraEvent")
local function avadakedavra(plr, hit)
local wand = game.StarterPack.Wand
if _G.spell == 1 then
_G.spell = 0
local ray = Ray.new(
plr.Character.Head.CFrame.p,
(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).magnitude
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
end
end
end
Client:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:WaitForChild("AvadaKedavraEvent")
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:Connect(function()
event:FireServer(mouse.Hit)
end)
Activation (LocalScript in Wand):
local player = game.Players.LocalPlayer
player.Chatted:Connect(function(msg)
local msg = msg:lower()
if msg:match("avada kedavra") then
_G.spell = 1
print("Player has typed in the spell.")
end
end)
Could someone help me on this?