Thank guys, none of this is working for me, I give up, I will just hire someone to do this for me, thanks!
Thank Vibe, none of this is working for me, I give up, I will just hire someone to do this for me, thanks!
Yeah sorry, I normally dont give up easily, but this constant deleting scripts and trying this and that for scripts that dont work, and then retrying the same scripts is too much. I will just pay someone.
I know that you can use TweenService and this way may be slower, but the LocalScript just makes the tween more customizable than a tween object. TweenObjects works fine as well but they may not always go in the speed you want the to go at and how much you want to change.
I also heard that you wanted stuff to happen when the Player touched the part.
For this, you will have to create a RemoteEvent. I suggest placing it in ReplicatedStorage and for testing purposes, name it βFOVChangerβ.
Scripts
LocalScript (Place in StarterPlayerScripts):
local RemoteEvent = game:GetService([[ReplicatedStorage]]):WaitForChild([[FOVChanger]])
local robloxFovLimit = {
min = 1;
max = 120;
default = 70;
}
local RunService = game:GetService([[RunService]])
local function pause(n)
local t = os.time()
repeat RunService.RenderStepped:Wait() until os.time() - t >= n
end
local camera = game.Workspace.CurrentCamera
local fovIsChanging = false
local function smoothFov(startFov, goal, fovPerInterval, interval)
if startFov == nil then startFov = camera.FieldOfView end
if startFov < robloxFovLimit.min or startFov > robloxFovLimit.max or goal < robloxFovLimit.min or goal > robloxFovLimit.max or startFov - goal == 0 or fovIsChanging == true then return end
fovIsChanging = true
for i = startFov, goal, fovPerInterval do
camera.FieldOfView = i
pause(interval)
end
fovIsChanging = false
end
RemoteEvent.OnClientEvent:Connect(smoothFov)
-- Usage example: smoothFov(camera.FieldOfView, 20, 0.3, 0.01)
ServerScript:
local RemoteEvent = game:GetService([[ReplicatedStorage]]):WaitForChild([[FOVChanger]])
local Part = game.Workspace.Part -- change this to wanted part
Part.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChildOfClass([[Humanoid]])
local Player = Humanoid and game.Players:GetPlayerFromCharacter(Humanoid.Parent)
local startingFOV = nil -- change to nil which sets to current fov or new starting fov (from 1 to 120)
local goalFOV = 20 -- change the rest of the variables to wanted value
local fovPerTick = 1 -- fov changes by this number every time a cetain amount of time passes
local fovChangeCooldown = 0.05 -- cooldown until fov ticks/changes
if Player then
RemoteEvent:FireClient(Player, startingFOV, goalFOV, fovPerTick, fovChangeCooldown)
end
end)
If you prefer to use a LocalScript only, use this script and place it in StarterPlayerScripts.
local Part = game.Workspace.Part -- change to wanted part
local LocalPlayer = game.Players.LocalPlayer
local robloxFovLimit = {
min = 1;
max = 120;
default = 70;
}
local RunService = game:GetService([[RunService]])
local function pause(n)
local t = os.time()
repeat RunService.RenderStepped:Wait() until os.time() - t >= n
end
local camera = game.Workspace.CurrentCamera
local fovIsChanging = false
local function smoothFov(startFov, goal, fovPerInterval, interval)
if startFov == nil then startFov = camera.FieldOfView end
if startFov < robloxFovLimit.min or startFov > robloxFovLimit.max or goal < robloxFovLimit.min or goal > robloxFovLimit.max or startFov - goal == 0 or fovIsChanging == true then return end
fovIsChanging = true
for i = startFov, goal, fovPerInterval do
camera.FieldOfView = i
pause(interval)
end
fovIsChanging = false
end
Part.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChildOfClass([[Humanoid]])
local Player = Humanoid and game.Players:GetPlayerFromCharacter(Humanoid.Parent)
if Player then
if Player == LocalPlayer then
local startingFOV = nil -- change to nil which sets to current fov or new starting fov (from 1 to 120)
local goalFOV = 20 -- change the rest of the variables to wanted value
local fovPerTick = 1 -- fov changes by this number every time a cetain amount of time passes
local fovChangeCooldown = 0.05 -- cooldown until fov ticks/changes
smoothFov(startingFOV, goalFOV, fovPerTick, fovChangeCooldown)
end
end
end)
-- Usage example: smoothFov(camera.FieldOfView, 20, 0.3, 0.01)
I truly apologize for all the errors Iβve made in the script, but please just take this updated version of the script as a last try. You really donβt have to spend on hiring people.
Alright Iβll give it a try for the last time.
Yeah still does not work for me and I followed every exact step and double checked.
Alright, for real just change the camera variable to game.Workspace.Camera. You really just have to press backspace on Current, pretty easy. Try that and if it doesnβt work, then you can do whatever you want. Sorry for making this difficult, I really donβt want you to be spending when there is no need. I read up on it and it showed that the FOV is only apart of the Camera, so that is definitely the problem there.
not trying to be that one annoying person, but i donβt think youβre supposed to directly ask for scripts here
maybe ask for ideas?
Change this part of the script right?
That is correct, change that part of the script.
You are being exactly what you tried not to be.
- Itβs too late for that comment as you can see.
- Itβs too late for that comment as you can see.
Alright, will give it a try shortly.
Youβre not being annoying. I understand that asking directly for scripts is against #scripting-support rules (well I do recall seeing a rule about it), but sometimes people are desperate and need it, so it can help them understand better. It could help them learn faster from it and not go searching everywhere with no success.
Yeah still doesnβt work thanks for the help Iβll just have to hire someone
β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β β
( Post deleted by author ) β β β β β β β β β β β β β β β β β β β β β β β β β β ββ β β β β β β β β β β β β β β β β β β β β β β β β β ββ β β β β β β β β β β β β β β β β β β β β β β β β β β
Have you set the Part variable though?
Not sure what you mean, whenever I tried to edit anything I got errors.
Iβm talking about this line, it specifically has a note saying to change the part variable to the part which you want to fire the function whenβs it is touchedβ¦
Also if you didnβt touch that line yet, then go do it. On top of that change the line in the last message that I told you to change back to game.Workspace.CurrentCamera