I'm making a flashlight Gui when you click the gui it turns on and off. I got the light working in starterplayerscripts, but can get the same effect from having a local script in Starterguis .
Here is my local script in the Gui in Starterguis
local player = game.Players.LocalPlayer local Character = player.Character local Light = player.Character.HumanoidRootPart.PointLight Light.Enabled = false script.Parent.MouseButton1Click:Connect(function() if player.Character then Light.Enabled = not Light.Enabled end end)
Here is the working local script in starterplayerscripts
local Character = script.Parent local Light = Instance.new("PointLight", Character:WaitForChild("HumanoidRootPart")) Light.Enabled = false Light.Color = Color3.fromRGB(0, 255, 0) Light.Brightness = 2 Light.Range = 10 Light.Shadows = true local UserInputService = game:GetService("UserInputService") local function onInputBegan(input) if input.UserInputType == Enum.UserInputType.Keyboard then if input.KeyCode == Enum.KeyCode.F then Light.Enabled = not Light.Enabled end end end UserInputService.InputBegan:Connect(onInputBegan)
Bruh I literally just answered someone else who did the same thing. You're supposed to use false.
Light.Enabled = false
I got it working replaced the gui local script with
script.Parent.MouseButton1Click:Connect(function() local player = game.Players.LocalPlayer local human = player.Character:FindFirstChild("HumanoidRootPart") local Light = human:FindFirstChild("PointLight") Light.Enabled = not Light.Enabled end)