I'm looking for a way to deal no damage to players in the game but still be able to damage NPC's in the game. Please take a look below Also the orb should be deleted after touching an NPC or continuing on a path to nowhere. It should also only damage an NPC once.
local mouse = game.Players.LocalPlayer:GetMouse() local orbtouch = false script.Parent.UseWand.OnServerEvent:Connect(function(Player)
local Orb = game.ReplicatedStorage.Small:Clone() Orb.CFrame = script.Parent.Parent.Handle.CFrame*CFrame.new(0 ,0, 0) Orb.Parent = workspace local BV = Instance.new("BodyVelocity", Orb) BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge) BV.Velocity = (mouse.hit.p - Orb.Position).unit * 65 BV.Parent = Orb function onTouch(Orb) local humanoid = Orb.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil) and humanoid.Parent ~= Player.Character then -- if a humanoid exists, then humanoid.Health = humanoid.Health - 100 orbtouch = true end if orbtouch == true then Orb.Destroy() end Orb.Touched:connect(onTouch) wait (2.5) Orb:Destroy() end
end)