This is the script I made, and it works, partially. TouchEnded is functioning properly, but the problem is that once TouchEnded is called it doesn't stay at brightness 0.
local function glowOnTouch(part)
local light = game.Workspace.plat1.SpotLight
local parent = part.Parent
if game.Players:GetPlayerFromCharacter(parent)then
repeat wait(.1)
light.Brightness = light.Brightness + .5
until light.Brightness ==10
wait(20)
end
end
local function stopGlowing(part)
local light = game.Workspace.plat1.SpotLight
local parent = part.Parent
if game.Players:GetPlayerFromCharacter(parent)then
light.Brightness = 0
end
end
game.Workspace.plat1.Touched:connect(glowOnTouch)
game.Workspace.plat1.TouchEnded:connect(stopGlowing)
