Hi, apologies if this is the wrong area to post this to, but I have a gun that has a flashing light when it fires but this lighting bug occurs on some shots, I would like to know if there is a fix or similar because it is very bright on windows and breaks the immersion
Have a look for yourself: (Flashing lights warning)
And here is the script that controls the pointlight: (Tween is declared above)
-- Pointlight
fp.PointLight.Enabled = true
fp.PointLight.Brightness = 20
if Tween then Tween:Pause(); Tween:Destroy(); end
Tween = TweenService:Create(fp.PointLight, TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Brightness = 0})
Tween:Play()
The code you provided has some errors and issues. Here are the corrections and suggestions:
The fp variable is not defined anywhere in the script. Make sure to define it before using it.
The Tween variable is not defined, and it’s being used in the script. You should define it first.
You’re checking if Tween exists before destroying it, but you should also check if TweenService exists since it’s required for creating new tweens.
Try this code instead:
local fp = script.Parent -- replace with the actual parent element
local TweenService = game:GetService("TweenService")
local Tween
fp.PointLight.Enabled = true
fp.PointLight.Brightness = 20
if Tween and TweenService then
Tween:Pause()
Tween:Destroy()
Tween = nil
end
Tween = TweenService:Create(fp.PointLight, TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Brightness = 0})
Tween:Play()
Remember this too; please replace script.Parent with the actual parent element you want to use.
In the video you can see like projection of the walls through the glass when the pointlight quickly turns on and off - I fairly sure its a graphical bug but It could also be that my pointlight is too bright and thats why I added the script
We sure do…
Setting the brightness to 0.4 or 0.3 makes the bug almost invisible, and I doubt the average player would notice but the effect for the light is also less visible but is definitely something I am willing to take over what was happening originally
print(v.Name)
if v:IsA("Tool") and v:FindFirstChild("Tool_Info") and v.Tool_Info:FindFirstChild("Combat") then
print(v.Name .. " is a combat tool")
v:Destroy()
end
end
for i, v in pairs(plr.Character:GetChildren()) do
if v:IsA("Tool") and v:FindFirstChild("Tool_Info") and v.Tool_Info:FindFirstChild("Combat") then
local humanoid = plr.Character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:UnequipTools()
end
v:Destroy()
end
end
local new_weapon = Weapon_Tools[plr.Data.Weapon.Value]:Clone()
new_weapon.Parent = plr.Backpack
Along with that to get the original effect you can add a ParticleEmitor (I spelt that wrong but don’t care), putting the particles at the end of the barrel