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

Why my light, color, and enabled doesn't work in this script?

So, I've been working on my horror game. And i don't know, why but this is not working.

local LightTrigger = game.Workspace.LightTrigger

LightTrigger.Touched:Connect(function(hit)
	if hit and hit.LightTrigger:FindFirstChild("Humanoid") then
		script.Parent.Parent.BrickColor = BrickColor.new(255,255,255)
		script.Parent.Enabled = true
		script.Parent.Parent.SurfaceLight.Enabled = true
			LightTrigger:Destroy()

	end
end)

2 comments

0

what is not working, where is the script located, is it not running at all or not destroying the light trigger on touch? Are there any errors in the output?

0

this question lacks a lot of informations

1 answer

assuming the script is in the trigger and the part you want to be changed is the parent of the trigger and both are parts, you could do

script.Parent.Touched:Connect(function(hit)
	local character = hit.Parent
	if character:FindFirstChild'Humanoid' then
		local part = script.Parent.Parent
		--         script.Parent.Enabled = true (dont think that is a thing)
		part.BrickColor = BrickColor.new('color')
		part.SurfaceLight.Enabled = true -- make sure theres a surface light in the part
		script.Parent:Destroy()
	else
		print'not player'
	end
end)

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