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

How do I check if player does not have light inside his torso already?

Asked by 2 years ago

Hello, I need help. I don't know how to check if player does not have light inside his torso already but it won't run the function, it seems like it can't check if its in it.

The script is:

return function()
script.Parent.Touched:Connect(function(t)
        if not t.Parent.Torso.Glow then
local glow = Instance.new("PointLight")
glow.Name = "Glow"
glow.Parent = t.Parent.Torso
glow.Range = script.Parent.Range.Value or 16
glow.Color = script.Parent.GlowColor.Value or Color3.fromRGB(255, 255, 255)
end
end)
end

Thanks for help!

0
Are you requiring the module script? Are you receiving any errors? If so, please post your code. COUNTYL1MITS 312 — 2y

1 answer

Log in to vote
2
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago
Edited 2 years ago

You should detect something not exist by using FindFirstChild. Because if they detect nothing, they return nil.

Example:

local Glow = t.Parent.Torso:FindFirstChild("Glow")

if Glow == nil then
    -- do what you want
end
0
Alright, thanks a lot! Canturion 6 — 2y
Ad

Answer this question