What do you want to achieve? I want my flashlight to flash/flicker continously (not the problem)
What is the issue? Whenever I try to get the Handle of the Flashlight tool thats inside a character it gives me the error Handle is not a valid member of LocalScript "Workspace.CraftyUnknown.Flashlight"
What solutions have you tried so far? Did you look for solutions on the Developer Hub? Yes I did.
Here is the code that causes the error:
function module.FlickerLights(seconds: number)
for _, v in pairs(game.Players:GetChildren()) do
local char = workspace:FindFirstChild(v.Name)
print(char:GetChildren())
if char and char:FindFirstChild("Flashlight") then
print(char.Flashlight:GetChildren())
task.spawn(function()
for i=seconds*2,0,-1 do
local tw = t:Create(char.Flashlight.Handle.Light,TweenInfo.new(.5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,true,0),{ Brightness = math.random(0,6)})
tw:Play()
wait(.5)
end
end)
end
end
end
Which line of the code is the error showing ? Also, as you can see the error saying “Not a valid member of LocalScript”. You may wrote something wrong.
Is there any script in your FlashLight ? Because the error is “Handle is not a valid member of LocalScript” So the handle is present in a LocalScript which is strange.
That means you are accessing it the wrong way, or it simply has no children.
What you can do is have a look inside your character in workspace. There you should find the Flashlight and see if it in fact has no children.
The first table in the picture are all the children in the character. The second table are all the children in the tool Flashlight (using print(char.Flashlight:GetChildren())). And the third “print” are the values “success” and “error” from the pcall() function.
Another thing that could be the cause is that the things aren’t properly loaded in yet.
try to acces the handle with local handle = char.Flashlight:WaitForChild("Handle"). That way you’d make sure it would wait until it’s loaded in.