Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Damage range with a part? [CLOSED]

I'm trying to make a part appear, and damage all players (except the client player) within the light's radius (inside the part, which is 16 by 16 by 16 inside a 16 range light). The entire script works, but the damage part is the part I'm trying to figure out. Sometimes it damages them, sometimes it doesn't. Please help. Oh, and, here's the script and the layout is here.

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.Lighting.Storage.collide:Clone()
		col.Parent = tool
		col.Position = handle.Position
		col.Anchored = false
		wait()
		light.Brightness = 100
		light.Range = 18
		wait()
		col.Touched:connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= player.Name and debounce == false then
				debounce = true
				hit.Parent.Humanoid:TakeDamage(10)
				debounce = false
			end
		end)
		for i = 1, 10 do
			wait(.01)
			col.Position = Vector3.new(0,.01,0)
		end
		light.Brightness = 1
		light.Range = 16
		tool:FindFirstChild("collide"):Destroy()
		wait(.2)
		Enabled = true
	end
end

script.Parent.Activated:connect(activated)

1 answer

✓ Accepted answer

I cannot be 100% sure this would work but

At line 20, try using

col.LocalSimulationTouched:connect(function(hit)

since this is a localscript.

That is sadly your best hope with a touched bullet in a localscript unless you use Raycast.

3 comments

0

Damn, didn't work. Do you know how to use Raycasting? Cause I sure as hell don't. x3

0

Search up Raycasting the how to make a Raycasting laser gun on wiki.roblox.com

0

I looked at that page, but I am trying to make area/splash damage, like an AoE attack in World of Warcraft, not just a laser gun.

This discussion is preserved as it was. New answers, comments, and votes are closed.