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

Servers don't free the Camera more than once each life? [closed]

Asked by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

I am making a cryo-freeze chamber which you can view in action here.

When you are frozen, CamFreeze is parented to your Character and run:

local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable

local val = script:WaitForChild("Value")

cam.CoordinateFrame = CFrame.new(
    val.Value,
    script.Parent.Head.Position
)

repeat wait() until script.Parent.Head.Anchored

cam.CoordinateFrame = CFrame.new(
    val.Value,
    script.Parent.Head.Position
)

script:Destroy()

And, when thawed, CamThaw:

local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = script.Parent.Humanoid

script:Destroy()

My problem is that CamThaw isn't fixing the Player's camera more than once each life. CamFreeze appears to work every time, but CamThaw only works the first time in online and Test Servers. (Test Server players are also unable to actually click the SurfaceGui button, but that's probably a ROBLOX bug as it works in Online Servers.)

What can I do to get this to work? I'm much prefer to have the camera manipulation, because otherwise the only way out of the chamber is to have someone else release you or to reset your character.

0
Is the CameraSubject changing? Like, if you do print(cam.CameraSubject) will it print Humanoid? Perci1 4988 — 9y
0
I dunno this code looks good. ZeptixBlade 215 — 9y
0
It prints "Humanoid" before and after. I changed the code in CamFreeze to set it to `nil`, and it will print `nil` before and `Humanoid` after, but it still doesn't work more than once. adark 5487 — 9y
0
If it actually IS changing the camera subject, then I don't know. I've run into errors like this before, where you change something but it doesn't behave as if changed. Probably a Roblox error. Perci1 4988 — 9y
0
Well that's annoying. I may have to resort to calling LoadCharacter on it, which requires a dozen more lines of sanity checking. :/ adark 5487 — 9y

Locked by adark

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

I reduced the two scripts to this:

-- Freeze
local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Scriptable
wait();
cam.CoordinateFrame = CFrame.new(10, 10, 10);
script:Destroy()
-- Thaw
local cam = workspace.CurrentCamera
cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = script.Parent.Humanoid
wait();
script:Destroy()

and it seemed to work as expected.

Perhaps the problem is the thing that is adding the localscripts, rather than the localscripts themselves?

1
The script adding the LocalScripts is working perfectly. The LocalScripts load and they will run print() statements, but it just wasn't working. I don't know why, but adding the wait() to the thaw LocalScript fixed the issue. Why would that matter? adark 5487 — 9y
0
When a script tries to delete itself as soon as it is parented, an exception is thrown. I'm not exactly sure why that would cause a problem in this case, though. BlueTaslem 18071 — 9y
0
I've seen the error before, and I wasn't even getting it here, the camera simply wasn't working. It works now, though, with the wait(). Very strange. adark 5487 — 9y
Ad