Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Damage range with a part? [CLOSED]

Asked by
hudzell 238 Moderation Voter
10 years ago

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

Log in to vote
1
Answered by
Bebee2 195
10 years ago

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.

0
Damn, didn't work. Do you know how to use Raycasting? Cause I sure as hell don't. x3 hudzell 238 — 10y
0
Search up Raycasting the how to make a Raycasting laser gun on wiki.roblox.com Bebee2 195 — 10y
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. hudzell 238 — 10y
Ad

Answer this question