Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How come my First-Person Compatibility script wont detect a change?

Asked by 3 years ago
Edited 3 years ago

I'm currently working on a First-Person Compatibility script but I don't want it to have my player locked into first person so I'm trying to make it where all the needed changes are made by using the GetPropertyChangedSignal, but it doesn't detect and I know that by using print("Changed") but it does not print that. What am I doing wrong?

---###--------[[SCRIPT]]--------###---

local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid

player:GetPropertyChangedSignal("CameraMaxZoomDistance"):Connect(function() ---Used to detect a change but does not do that.
    print("Changed") ---Should print when CameraMaxZoom Changes.
    if player.CameraMaxZoomDistance == 0.5 then
        camera.FieldOfView = 100
        humanoid.CameraOffset = Vector3.new(0, 0, -1)
    elseif player.CameraMaxZoomDistance >= 0.5 then
        camera.FieldOfView = 70
        humanoid.CameraOffset = Vector3.new(0, 0, 0)
    end
end)
0
It seems to have no wait in there, try humanoid = character:WaitForChild"Humanoid" to make sure this only runs once the humanoid is loaded in.  AlexanderYar 788 — 3y
0
Also do same with camera just in case AlexanderYar 788 — 3y
0
Make it a habit AlexanderYar 788 — 3y
0
But speaking of the actual problem, when debugging, put prints everywhere, so put it before the connect function. Its a good habbit to debug this way also i got reminded of it bc i dont see why the code wont work, so maybe the script is disabled or doesnt run for a reason AlexanderYar 788 — 3y
0
Or maybe what ever is supposed to change that value doesnt, look at that script to. Other than that, try changing it manually while in testing mode so you know for a fact it should run and the problem cant be that. If it doesnt work then eithe rthe code is wrong or the script is disabled or in a place that doesnt let it work AlexanderYar 788 — 3y

Answer this question