How to change a value when a player clicks button for that single player

hello im trying to make a notification that tellls the player there are flashing lights and it gives them to option to turn it off.

im creating a new folder inside of player with the values 1,2 which tell the lights to flash or not.
im trying to change that value inside of the textbutton when clicked.

  • heres the scripts:

script to button:

local click = false
script.Parent.MouseButton1Click:Connect(function()
	local click = not click

	if click == true then
		game.Players.LocalPlayer.SettingsFolder:WaitForChild("FlickeringLights").Value = 2
		script.Parent.Text = "Turned Off"
		script.Parent.BackgroundColor3 = Color3.fromRGB(0, 255, 115)
	elseif click == false then
		game.Players.LocalPlayer.SettingsFolder:WaitForChild("FlickeringLights").Value = 1
		script.Parent.Text = "Turned On"
		script.Parent.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
	end
end)

script to the value creator located in scriptstorage

game.Players.PlayerAdded:Connect(function(plr)

local SettingsFolder = Instance.new("Folder")

SettingsFolder.Name = "SettingsFolder"

SettingsFolder.Parent = plr

local FlickeringLights = Instance.new("IntValue")

FlickeringLights.Name = "FlickeringLights"

FlickeringLights.Parent = SettingsFolder

FlickeringLights.Value = 1

end)

end)

script to lights

local light = script.Parent.PointLight
local part = script.Parent
local disabled = light.Brightness
local Light = light.Range
if game.Players.LocalPlayer.SettingsFolder:WaitForChild("FlickeringLights").Value = 1 then
while true do 
		wait()
		disabled = 0.2 light.Brightness = 0.2 part.Material = "Neon"
		wait(math.random(0.6, 0.8))
		disabled = 0 light.Brightness = 0 part.Material = "Glass"
		wait(math.random(0.6, 0.8))
	disabled = 0.2 light.Brightness = 0.2 part.Material = "Neon"
		wait(math.random(0.6, 0.8))
	disabled = 0 light.Brightness = 0 part.Material = "Glass"
		wait(math.random(0.6, 0.8))
	disabled = 0.2 light.Brightness = 0.2 part.Material = "Neon"
	wait(math.random(1, 3))
	disabled = 0 light.Brightness = 0 part.Material = "Glass"
		wait(math.random(0.6, 0.8))
	disabled = 0.2 light.Brightness = 0.2 part.Material = "Neon"
wait(math.random(0.6, 0.8))
	end

Ya mean Creating a Count Statement?

yea how do i “Create a count statment?”

Instead of inserting a folder on player insert a bool value into the flashlight, then when this value is true, flashlight turns on

im going to have like 50 lights that flash. would it be For i,v in pairs and loop thro to see if its name flshing light etc?

can i do that in a local script as well? i want it to only apply to that one person

OK so i added a bool value into pointlight. do i do this? if script.Parent == true then in the light script

if script.Parent == true then
-- Flashlight turned on here
script.Parent = false
elseif script.Parent == false then
 -- Flashlight turned off here
script.Parent = true

I think you’re not understanding

image

you just need 1 value, and when player clicks, you’ll set the value to true and then flashlight turns on

its a ceiling light not a flashlight btw. like its a ceiling light that flickers

Oh God, now I understand the situation.

If Gui is clicked then and can only seen by one person(local script)
Use Bindable Function

Can i get a script example? thank you

that articles example isnt related to my quiry

You still don’t need a folder add the value in starter player, so if this value is true all lights will flick, else lights will not flick

1 Like

yea that seem easier. ill try it out

This seems like a nice solution to this problem.

Sorry for the problem I created

I dont know how to invoke() things and i intend on fixing the problem for now