Flashlight script stops working after the player dies

i’ll give that a try i suppose, what the heck is replicatedstorage then? i thought it was a server thing and if i put a event in there it’d activate every script listening

nope, you might though of “ServerStorage” which is only accessible by the Server.

ReplicatedStorage is mostly used for storing modules and remotes (Remote Events & Remote Functions)

that fixed it, thanks man i appreciate the help a lot (:>

1 Like

tested it with some friends and apparently this activates all the flashlights?

Oh ye, you should get the player instace from the remote event and then take his character

1 Like
wait(1)
local FLS = false


 


function lightstate(player)
local char = player.Character
local bodylight = char.bodylight
local on_indi = bodylight.on_indi
local off_indi = bodylight.off_indi
local flashlightclick = bodylight.main.FlashlightClick

	if FLS == false then 
	bodylight.lamp.SpotLight.Brightness = 2
	bodylight.outterlamp.PointLight.Brightness = 0.5
	bodylight.lamp.Material = Enum.Material.Neon 
	bodylight.lamp.Color = Color3.fromRGB (255, 255, 255)
	on_indi.Color = Color3.fromRGB (0, 255, 0)
	off_indi.Color = Color3.fromRGB (0, 0, 0)
	flashlightclick:play()	
	FLS = true
	wait(2)
	elseif FLS == true then 
	bodylight.lamp.SpotLight.Brightness = 0		
	bodylight.outterlamp.PointLight.Brightness = 0	
	bodylight.lamp.Material = Enum.Material.SmoothPlastic 	
	bodylight.lamp.Color = Color3.fromRGB (0, 0, 0)	
	on_indi.Color = Color3.fromRGB (0, 0, 0)
	off_indi.Color = Color3.fromRGB (255, 0, 0)	
	flashlightclick:play()		
	FLS = false
	wait(2)	
	end
end

function wipe(player)
local char = player.Character
	print("cleaning up!")
	char.magazine:Destroy()
	char.Union:Destroy()
	char.armor:Destroy()
	char.flashlight_I_O:Destroy()
	script:Destroy()
end

man.flashlight_I_O.OnServerEvent:Connect(lightstate)
man.deathevent.OnServerEvent:Connect(wipe)

how do you do that? not super experienced with this kinda stuff

nvm got it lol thanks for the help man!

1 Like