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

Most of a script runs, but "skips" over other lines. Any ideas?

Asked by 5 years ago

Okay. I'm real stumped about this one. I wouldn't say I'm an 'experienced' LUA person, but my knowledge has allowed me to help revamp a game known as 'Steven Universe: 3D Roleplay' with my friend Firelexy. I've become the main scripter since then, and we decided to try out something new: sending data between 'places' using that feature ROBLOX added.

What I'm trying to accomplish is sending current Morph data, including morph name, class, and CameraOffset (we use this to relocate the camera to the head of the morph). Most of it works, however, some lines mysteriously do not work.

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

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)
Player.Character.Humanoid.CameraOffset = Vector3.new(offset)
if char == "NullDefaultMorph" then
    print("No Morph!")
else
    game.Workspace.MorphFuncs.PlayerClear:FireServer()
    game.Workspace.MorphFuncs:WaitForChild((char)):FireServer()
end

Most of everything you see here will work, when I teleport from one place to the other, it receives the data (I have it print what it receives), it will apply the morph to the character, however, it seems as if it 'skips' the CameraOffset line and firing the PlayerClear event.

The odd thing is they do not report any errors in the console, both in Studio and in game, in fact when I manually morph, they work just fine. This has been an ongoing issue since the beginning of my work, and I do not understand why. Anyone who's more wise, please spare my soul from LUA hell!

0
Try to print() things, for debugging, they usually help to spot where is the error. OfcPedroo 396 — 5y
0
@OfcPedroo I did add print() lines to the lines that are being problematic, but they get through and print as if nothing is wrong. However, there seems to be an inconsistency, where this time, the PlayerClear() event did work, but not the CameraOffset. JosefuAto 4 — 5y
0
One thing to note however, I did add a wait() to the beginning of the script, which lets it wait for the player to 'load in', which may explain why that event works (it's purpose is to remove all hats.) JosefuAto 4 — 5y
0
What's `that feature`? TheeDeathCaster 2368 — 5y
View all comments (3 more)
0
The feature that lets you send data when you teleport between two games, the TeleportService. JosefuAto 4 — 5y
0
side note: lua is not an acronym it doesnt stand for anything it's the portuguese word for "Moon" hence the logo please do not capitalize it vanilla_wizard 336 — 5y
0
Not the most useful comment there about capitalizing lua, but okay. JosefuAto 4 — 5y

Answer this question