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)

2 comments
LOLLLLLLL no one knows that true and false exists
Do you mean replace the ~~~~~~~~~~~~~~~~~ Light.Enabled = not Light.Enabled ~~~~~~~~~~~~~~~~~ with
~~~~~~~~~~~~~~~~~ Light.Enabled = false ~~~~~~~~~~~~~~~~~Because that didn't work,? the problem seems to be that, the scrip don't know where the light is.