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

'Ghost' Frame Moves with TweenPos, Doesn't Move on Screen?

Asked by
x_Tso 48
4 years ago
Edited 4 years ago

Sorry for the confusing title.

To summarize the issue, there's a portion of a script I'm using that seems to be moving what I can only describe as a "ghost" version of the frame in question. It uses TweenPosition, and it's literally only meant to fly a frame across the screen. However, while I find that by looking in the properties of the frame that's supposed to be moving, I can see the position constantly being changed due to the TweenPosition being active, I find that, when looking at the frame on screen, it doesn't seem to be doing anything.

Here's the portion of the code responsible for moving the frame.

game.StarterGui.BattleTrans.Indicator:TweenPosition(
    UDim2.new(-2, 0, 0.5, 0),
    "Out",
    "Quad",
    3
)

That's the only code that's being used to move the frame. And yes, I'm not stupid, because the frame being moved is in StarterGui, within a ScreenGui named "BattleTrans," and the frame's name is "Indicator." The code is within a LocalScript, and that LocalScript is a folder named "Test0001," which is in another folder named "BattleActivations," which is all found in StarterGui. (if that made no sense, this is code that could be used to find the LocalScript):

game.StarterGui.BattleActivations.Test0001.Start0001

So, when this code is activated, the frame on screen doesn't seem to move at all. So, I go to look in the properties of this frame, and I end up finding that, despite it not moving on screen at all, the frame's position property is constantly updating as if it was moving. As in, the position property of the frame changes, but, despite this, the frame itself doesn't move one bit on screen. I tried some pretty dumb things to troubleshoot. I thought, maybe it could fix it if I used a local variable instead of the frame in it's position, ending with code like this:

local ind = game.StarterGui.BattleTrans.Indicator
ind:TweenPosition(
    UDim2.new(-2, 0, 0.5, 0),
    "Out",
    "Quad",
    5
)

I tried moving all of the folders the LocalScript was contained into different places, such as StarterPlayerScripts. Nothing changed. I thought maybe it was a weird Studio bug. It also didn't work when playing in-game, and not in Studio. I'm happy to answer any further questions, because it does seem to be a weird issue, and I'm not finding any solutions to it so far. Will keep looking online for similar problems from other people. The part does use AnchorPoints (x = 0.5 & y = 0.5, this just keeps it centered on all screen sizes) if that affects the issue. The parts AbsolutePosition property does also seem to be changing as well.

Please help! This problem is blocking me from starting a test battle for my new MMO game, and I don't want it to slow down development at all. I do remember encountering the issue in the past. The solution was janky, and definitely wasn't meant to be a permanent fix. I don't remember exactly what I did, but it used two scripts and some small change in the TweenPosition code or something. One script only seemed to change the frame's position property, and not move the frame on screen. The other script didn't change the frame's position, but still managed to move the frame on screen. I literally have no clue what's going on. Feel free to see if the problem replicates in your Studio. Again, it's probably a super small fix.

Thanks! -x_Tso

(edit: some more probably useless information: the game does allow Studio access to API services. if that somehow is related. just tying to throw in every possibility)

(edit again: i found the solution under a completely different problem. my mistake is listed below, in case any future scripter runs into the issue.)

Turns out, you can't use StarterGui to index a Gui. Apparently, when a player spawns, the Guis on the screen are not the children of StarterGui, but rather cloned into what is known as "PlayerGui," a 'folder' of Guis that only spawns when the player spawns. So, rather than saying "game.StarterGui," I would have to access / index the frame by using PlayerGui, or just by using all the "script.Parent"'s necessary to reach the frame. So yes, the Guis on screen are not the same Guis that are present in the StarterGui folder in the Explorer tab.

Answer this question