#Zooming, and Mouse Scroll Wheel stuff
53 messages · Page 1 of 1 (latest)
That means you did something wrong with the handling
can u show the code again or did you fifx it
i got it working now, but ill send you the portion that i got working to see if you can help me understand what couldve went wrong
i deleted the old code before you typed so i cant get it back
local function FlashlightToggle()
if FlashL.Enabled == true then
FlashL.Enabled = false
elseif FlashL.Enabled == false then
FlashL.Enabled = true
end
end
local function ZoomingFORWARD()
if FlashL.Range == FlashL.Range then
FlashL.Range = math.clamp(FlashL.Range + add, 15, 60)
end
end
local function ZoomingBACKWARD()
if FlashL.Range == FlashL.Range then
FlashL.Range = math.clamp(FlashL.Range - sub, 15, 60)
end
end
-- Connecting --
UIS.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.F then
FlashlightToggle()
end
end)
Mouse.WheelForward:Connect(ZoomingFORWARD)
Mouse.WheelBackward:Connect(ZoomingBACKWARD)```
working code
im thinking it has to do with something i did in the "Flash.Range = math.clamp(FlashL.Range + add, 15, 60)", cuz i had variables set up for the default range of the light, which was a value instead of the actual property
Btw for the FlashlightToggle you can simplify and to "FlashL.Enabled = not FlashL.Enabled
pretty much short for "toggle != toggle"
Yes that was the problem
i was thinking that!! thank you for helping ^^
but can you explain this a little more please? /nf
i didnt see ur old code but you might of tried to add a value to the range instead of the actual property?
yeh thats exactly how it was
lemme try to recreate it
if FlashL.Range == FlashL.Range then
FlashL.Range = math.clamp(defRange + add, 15, 60)
end
end```
for context, "defRange" is a variable i have set up to equal 15
and "add" is a variable equal to 1
yup
your add and defrange which is a constant value of 15. Which means no matter how much times u scroll with your mouse the flashl.range will always be clamped to a value between 15 and 16
yehh, i figured that out when i added the actual range property inplace of defRange
makes a looot more sense now
thank you so much!! <3
ok i might actually need help with something else now @heavy surge
yes?
So here's a video of the flashlight working, I'm wanting to now make it to where it'll smoothly change the range and angle instead of being choppy like this
have u tried tweening?
I'm trying to use Tweens to do that, but it's messing with the actual part of the code that changes the range, and makes it lose range (for some reason)
et me take a look at the code
-- Important --
local Mouse = Plr:GetMouse()
local FlashL = Instance.new("SpotLight")
local angle = 54
local defRange = 15
-- Flashlight Properties --
FlashL.Enabled = false
FlashL.Brightness = 2.2
FlashL.Range = defRange
FlashL.Angle = angle
FlashL.Shadows = true
FlashL.Parent = Head
-- Possible --
local Rangeadd = 2.8
local Rangesub = 2.8
local Angleadd = 6.7
local Anglesub = 6.7
local goal = {}
goal.Range = Rangeadd
goal.Range = Rangesub
goal.Angle = Angleadd
goal.Angle = Anglesub
local RangeADDtween = TS:Create(FlashL, TInfo, goal)
local RangeSUBtween = TS:Create(FlashL, TInfo, goal)
-- Functions --
local function FlashlightToggle()
if FlashL.Enabled == true then
FlashL.Enabled = false
elseif FlashL.Enabled == false then
FlashL.Enabled = true
end
end
local function ZoomingFORWARD()
if FlashL.Range == FlashL.Range then
RangeADDtween:Play()
FlashL.Range = math.clamp(FlashL.Range + Rangeadd, 32, 60)
if FlashL.Angle == FlashL.Angle then
FlashL.Angle = math.clamp(FlashL.Angle - Anglesub, 27, 90)
end
end
end
local function ZoomingBACKWARD()
if FlashL.Range == FlashL.Range then
RangeSUBtween:Play()
FlashL.Range = math.clamp(FlashL.Range - Rangesub, 32, 60)
if FlashL.Angle == FlashL.Angle then
FlashL.Angle = math.clamp(FlashL.Angle + Angleadd, 27, 90)
end
end
end```
i might know why, but im not too sure either
local TweenService = game:GetService("TweenService")
local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
local Head = Plr.Character.Head
local FlashL = Instance.new("SpotLight", Head)
FlashL.Enabled = false
FlashL.Brightness = 2.2
FlashL.Range = 15
FlashL.Angle = 54
FlashL.Shadows = true
local TInfo = TweenInfo.new(2, Enum.EasingStyle.Linear)
local Rangeadd = 2.8
local Rangesub = 2.8
local Angleadd = 6.7
local Anglesub = 6.7
-- Functions --
local function FlashlightToggle()
if FlashL.Enabled == true then
FlashL.Enabled = false
elseif FlashL.Enabled == false then
FlashL.Enabled = true
end
end
local function ZoomingFORWARD()
local goal = {}
goal.Range = math.cl(ampFlashL.Range + Rangeadd, 32, 60)
goal.Angle = math.clamp(FlashL.Angle - Anglesub, 27, 90)
local tween = TweenService:Create(FlashL, TInfo, goal)
tween:Play()
end
local function ZoomingBACKWARD()
local goal = {}
goal.Range = math.clamp(FlashL.Range - Rangesub, 32, 60)
goal.Angle = math.clamp(FlashL.Angle + Angleadd, 27, 90)
local tween = TweenService:Create(FlashL, TInfo, goal)
tween:Play()
end
You can try this
I dont think it looks choppy
yeh youre not wrong, i js would like it to be a bit smoother
** You are now Level 4! **
The tween will always use the value of the FlashL.Range and FlashL.Angel when it starts then it will tween towards the goal values
yehhh thats what i was thinking after seeing that, i forgot it actually messes with the values
anyways im gonna try and finish the rest of this flashlight! ill let yk if i need help with anything ^^
so i might need help with 2 small things @heavy surge you ok with that?
sure
alr gimme a sec
im implementing a blacklight system to where when i press Q while the normal flashlight is on, it changes to the blacklight and its properties. the problem is when i enable the blacklight, i can also enable the flashlight with it, making a weird effect
hello?
ah there we go
smt weird happened lol