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

No errors, yet line of code setting CameraOffset seemingly doesn't excute. What's the issue?

Asked by 5 years ago

Greetings! I have asked this question before, but I might as well give it another shot, reword a few things, and clear up some points I may have confused some people on in my original post.

The purpose of this script is to receive morph/character data from a place and use that data to "remorph" the player back to the character they were previously playing. Almost everything is working! Almost.

Player = game.Players.LocalPlayer
repeat wait() until Player.Character
local Character = Player.Character
Character:WaitForChild("Humanoid")

wait(1.0)
local teleport = game:GetService("TeleportService")
local teleportdata = teleport:GetLocalPlayerTeleportData()
if teleportdata then
    print(teleportdata.charName)
    print(teleportdata.charClass)
    print(teleportdata.offset)
    local char = (teleportdata.char)
end
char = (teleportdata.char .. 'Morph')
offset = teleportdata.offset
script.parent.TextLabel.Text = (char)
wait(0.5)
Player.Character.Humanoid.CameraOffset = Vector3.new(offset)
print("Camera Offset")
wait(0.5)
if char == "NullDefaultMorph" then
    print("No Morph!")
else
    game.Workspace.MorphFuncs.PlayerClear:FireServer()
    print("Clear Player")
    game.Workspace.MorphFuncs:WaitForChild((char)):FireServer()
    print("Player Morph")
end

Line 19 is the culprit here. I have token advice from others to use print() to see if something would pop up, but nothing. ROBLOX Studio reports no errors, the in-game console reports no errors, and yet, the Player CameraOffset does not change at all. It's as if it ignores that line.

I've had many other lines of code do this to me, some I had to fix using what would be almost unethical ways just to get it to work. This has stumped me for some time. Could anyone give insight? I don't know if it's a matter of optimization, or something I am completely unaware of.

Thank you!

0
Why is char wrapped in parenthesis everywhere User#19524 175 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Why it's Difficult to Help

When you teleport someone from one game to another and send TeleportData, you send a table of values that you make yourself. You didn't post the script that teleported the player, therefore we do not know what type of value teleportdata.offset is.


My Hypothesis

I don't have your first script, so this is just an educated guess. If you look at the wiki page for Vector3 and you look at the first constructor, you will see that in order to construct a new Vector3, you need an x,y and z, all of them need to be numbers. If they aren't numbers, ROBLOX will default it to 0. For example:

print(Vector3.new())
--0 0 0 because unknown values default to 0

print(Vector3.new(3,2))
--3 2 0 because the last value is unknown; defaults to 0

print(Vector3.new(true, workspace))
--0 0 0 all 3 values are not numbers; they default to 0

print(Vector3.new(Vector3.new(2,3,4)))
--0 0 0 even though we have a vector3 inside, the vector3 value is not a number.

print(Vector3.new(nil, 3, BrickColor.Random()))
--0 3 0 because first and last value are not numbers, but the y is.

Final Product

--Line 19:
Player.Character.Humanoid.CameraOffset = offset

No need for Vector3.new because offset is already a Vector.



Hope it helps!

0
Thank you good sir! JosefuAto 4 — 5y
Ad

Answer this question