Hello Scripters! Im sitting here with the problem i couldnt solve, even with searching on youtube and the devforum etc.
my Problem simply is that I cant change values of a “DepthOfField” in my Lighting just by a LocalScript which is in StarterGui/PlayerGui.
it is playing a cutscene when you sit in a Chair by pressing E, when pressing E (Triggering the Proximity prompt) the cutscene will play and it (should) change(s) the Far Intensity and the InFocusRadius of the DepthOfField.
The Cutscene should only play for the player who pressed E to sit on the Chair. The cutscene is working but it is not changing anything on the DepthOfField and is not giving me a error aswell.
for i = 1,10 do
game.Lighting.DepthOfField.FarIntensity = game.Lighting.DepthOfField.FarIntensity + .1
game.Lighting.DepthOfField.InFocusRadius = game.Lighting.DepthOfField.InFocusRadius + .5
end
As I said, please remember it should only change the DepthOfField Settings for the client, so remoteevent or so is not going to work, Thanks to everyone reading this!
Oh yeah and is this entire code, can you make sure that it even gets ran, by using prints.
What your code does is only make it harder to see further away, make it blurry as well a make the radius, so how far you can see bigger.
Please elaborate on what you want to achieve.
here is a video, as you can see the cutscene is playing and by the printing it should smoothly change the values of the DephOfField, in the lighting settings of DephOfField it is showing the changed [on client as i want it to] but it does not change anything in the game for the player himself. I want the DephOfField to be focused on the players face and the background should be blurred out.
Can you make sure there are not any other DepthOfField effects, these can hinder the selected DepthOfField effect. Another thing which might cause this is having low render distance, then you will barely be able to see any effect. So make sure to disable automatic rendering and put it all the way to the top.
Quick question, what effect are you trying to make, because the effect you got right now just moves the DepthOfField away and makes the blur intensity further away higher.
I could try to see if you maybe wrote it wrong if you could tell me what you want to achieve.
So I am assuming you want the Depth of Field to get near the player so that means we will have to lower the FocusDistance and the InFocusRadius, so instead adding to it like you are doing there. Do something more like:
local DepthOfField = game:GetService("Lighting"):WaitForChild("DepthOfField")
for i = 0,1,.1 do task.wait(.1)
DepthOfField.FarIntensity += .1
DepthOfField.InFocusRadius -= 1
DepthOfField.FocusDistance -= .5 -- half of the radius
end
Okay so scrap that for loop, let’s instead use TweenService, first test around with the values you want the DepthOfField to result in, then put them into the tween like so:
-- Variable, on top
local TweenService = game:GetService("TweenService")
-- Run this
local tween = TweenService:Create(DepthOfField,
TweenInfo.new(1), { -- the 1 stands for how long it will take to complete
-- ["PropertyName"] = Value you want it to end on,
["FarIntensity"] = 1,
["InFocusRadius"] = 1,
["FocusDitance"] = 1,
})
tween:Play()