My flashlight script is too sensitive

Hello! I am making a flashlight script. But, my flashlight seems too sensitive and I don’t know how to fix it.
Here’s the code:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function()
		local flashlight = Instance.new("Part",plr)
		flashlight.Name = "flashlight"
		flashlight.Parent = plr.Character
		flashlight.Transparency = 1
		flashlight.Size = Vector3.new(1,1,1)
		local weld = Instance.new("Weld",plr.Character.Head)
		weld.Parent = plr.Character.Head
		weld.Part0 = weld.Parent
		weld.Part1 = flashlight
		flashlight.Massless = true
		local sound = game.ReplicatedStorage.flashlight:Clone()
		sound.Parent = flashlight
		local spotlight = Instance.new("SpotLight",flashlight)
		spotlight.Brightness = 5
		spotlight.Range = 25
		spotlight.Enabled = false
		while wait() do
			local hitP = game.ReplicatedStorage.RemoteFunction:InvokeClient(plr)
			weld.C1 = CFrame.new(0,0,.3)
			local e = CFrame.new(flashlight.Position,hitP):ToObjectSpace(flashlight.CFrame)
			weld.C1 = e
		end
	end)
end)
game.ReplicatedStorage.Turn.OnServerEvent:Connect(function(plr)
	if plr.Character and plr.Character:FindFirstChild("flashlight") then
		print("E")
		plr.PlayerGui.ScreenGui.flashlight:Play()
		plr.Character.flashlight.SpotLight.Enabled = not plr.Character.flashlight.SpotLight.Enabled
	end 
end)

Thank you!

1 Like

Is there any errors in your code? And also the output “E” on your code?

What exactly do you mean by too sensitive?
The movement?
The ability to turn it on and off too quickly?

Also, why not create the tool complete with welds, Massless, Spotlight etc. and put it in the backpack? This would make it a lot easier and less susceptible to errors.

1 Like

The movement is the problem. It’s too fast.

? if you want a flashlight script here is a good one i made a few weeks ago for a cancelled project (local script btw)

local Players = game:GetService("Players")
local clicksound = script:WaitForChild("Flashlight On Off Clicks 15 (SFX)")

local i = 100
local value = i
local failsafe = i > 100

script.Parent.Activated:Connect(function(s)

	if script.Parent.Handle.SurfaceLight.Enabled == true then
		
		script.Parent.Handle.SurfaceLight.Enabled = false
	clicksound:Play()
	else
		
		script.Parent.Handle.SurfaceLight.Enabled = true
	clicksound:Play()
	end
	
	while script.Parent.Handle.SurfaceLight.Enabled == true do
		wait(1)
		i = i - 1
		print("Life Has Gone Down")

		if i < 1 then
			print("Battery Has Died")
			script.Parent.Handle.SurfaceLight.Enabled = false
			script.Enabled = false
		end
	end

	if failsafe then
		Players.LocalPlayer:Kick("You have been caught cheating.")
		print("Battery Cheating")
	end

end)

script.Parent.Unequipped:Connect(function(s)
	script.Parent.Handle.SurfaceLight.Enabled = false
	local truei = i
	print(i)
	wait(1)
	i = truei
	print(i)
end)
1 Like