0 views0 copies0 likes

Personal Flashlight That Survives Resets

Universal script

Copy it, then test it in your own Studio place.

UI systems Verified

Script code

16 lines ยท 0.7 KB
Download
local Actions = game:GetService("ContextActionService")local player = game:GetService("Players").LocalPlayerlocal lightlocal function bind(character)	local head = character:WaitForChild("Head")	light = Instance.new("SpotLight", head)	light.Face, light.Angle, light.Range = Enum.NormalId.Front, 65, 24	light.Brightness, light.Enabled = 2, falseendplayer.CharacterAdded:Connect(bind)if player.Character then task.spawn(bind, player.Character) endActions:BindAction("ToggleFlashlight", function(_, state)	if state == Enum.UserInputState.Begin and light and light.Parent then light.Enabled = not light.Enabled end	return Enum.ContextActionResult.Sink-- โ€ฆopen Get script for the full source

About this script

This LocalScript adds a Flashlight action to your own cave or night map. Press F or tap the action button to toggle a SpotLight on the current character's head. It recreates the light after a character reset and starts turned off. Tune Angle, Brightness and Range to keep paths readable without lighting the entire room. Try it once on mobile emulation as well as with a keyboard.

Comments

Share what works, ask questions, or report an issue.

0

Log in to leave a comment.

No comments yet

Be the first to share your thoughts!

Raw Luau source

local Actions = game:GetService("ContextActionService")
local player = game:GetService("Players").LocalPlayer
local light
local function bind(character)
	local head = character:WaitForChild("Head")
	light = Instance.new("SpotLight", head)
	light.Face, light.Angle, light.Range = Enum.NormalId.Front, 65, 24
	light.Brightness, light.Enabled = 2, false
end
player.CharacterAdded:Connect(bind)
if player.Character then task.spawn(bind, player.Character) end
Actions:BindAction("ToggleFlashlight", function(_, state)
	if state == Enum.UserInputState.Begin and light and light.Parent then light.Enabled = not light.Enabled end
	return Enum.ContextActionResult.Sink
end, true, Enum.KeyCode.F)
Actions:SetTitle("ToggleFlashlight", "Light")