I am trying to make a weapon (Light Orb, in my place Lights) with a raycasting area splash damage that damages all players except the client player within a certain distance. I have tried, but it failed completely. Here is the code, and here is the Layout also. Please help me, I am stuck and really confused >_<
local tool = script.Parent local handle = tool.Handle local light = handle.PointLight local player = game.Players.LocalPlayer local Enabled = true local debounce = false function activated() if Enabled == true then Enabled = false wait() local col = game.ServerStorage.collide:Clone() col.Parent = tool col.Position = handle.Position col.Anchored = false wait() light.Brightness = 100 light.Range = 18 wait() col.LocalSimulationTouched:connect(function(hit) local ray = Ray.new(handle (360)) local ignore = game.Players.LocalPlayer.Character local hit, position = Workspace:FindPartOnRay(ray, ignore) end) light.Brightness = 1 light.Range = 16 tool:FindFirstChild("collide"):Destroy() wait(.2) Enabled = true end end script.Parent.Activated:connect(activated)
Ok, I'm going to answer this on the assumption that you won't care about terrain damage. Instead of casting a ray in every direction from the orb (or wherever you want it to come from), Cast a ray to each player and check the distance from the player/if there is an object in the way (a wall for example). This way it is easy to check if a player is within the 'blast radius' and to ignore damage for the user. Let me know if you need any help implementing this or is it won't work at all for your idea :)
First of all, I'd like to say that's alot of work. I like your idea, it sounds cool.
The most efficient way in making this, is to try a function, so it's organized, and it's seperate from everything else.
I am not too good at distant, like scripts. But if you try "x", and "y", and put together a position width for the tool, as a string, it possibly can work.