Issue with TweenPosition

i want to make it that whenever someone captures the flag in my game, a gui slides across the screen that says the flag was captured.

function tweenCaptureDisplay()
captureDisplay.Position = originalPos
captureDisplay:TweenPosition(
UDim2.new(1.3, 0, 0.31, 0),
Enum.EasingDirection.In,
Enum.EasingStyle.Quart,
1.5,
true
)
end

local function redCapture ()
if gameOnValue == true then
captureDisplay.TextColor3 = Color3.new(1,0,0)
captureDisplay.Text = “Blue’s flag was captured!”
tweenCaptureDisplay()
end
end

local function blueCapture()
if gameOnValue == true then
captureDisplay.TextColor3 = Color3.new(0,0,1)
captureDisplay.Text = “Red’s flag was captured!”
tweenCaptureDisplay()
end
end

I have ran the function tweenCaptureDisplay by itself and it worked, but when I try to call it within these functions, which are connected with a changed event, the tweening does not play. Is there something I’m doing wrong? If so, what?

1 Like

Please use codeblocks to make your code easy to read.

1 Like

sorry, how do you put your code in codeblocks?

```lua
– Do something here
```

Use code blocks, this is how.

--Use the thing on the ~ key 3 times at the beginning and the at the end.
```Code```
--just mess around with it, you'll get it.
function tweenCaptureDisplay()
	captureDisplay.Position = originalPos
	captureDisplay:TweenPosition(
		UDim2.new(1.3, 0, 0.31, 0), -- final pos --
		Enum.EasingDirection.In,
		Enum.EasingStyle.Quart,
		1.5,
		true
	)
end

local function redCapture () -- if red team gets a point
	if gameOnValue == true then
		captureDisplay.TextColor3 = Color3.new(1,0,0)
		captureDisplay.Text = "Blue's flag was captured!"
		tweenCaptureDisplay()
	end
end

local function blueCapture()-- if blue gets point
	if gameOnValue == true then
		captureDisplay.TextColor3 = Color3.new(0,0,1)
		captureDisplay.Text = "Red's flag was captured!"
		tweenCaptureDisplay()
	end
end
2 Likes

I assume this is being done in a player’s local script, and I also assume that points are scored and given by the server and some sort of objects value is being changed.

perhaps instead of using a .changed event use getpropertychangedevent

RedScoreObject:GetPropertyChangedSignal("Value"):Connect(redCapture)

I tried this just now. I did not really get any response, but I feel like I might know what my issue could be. When, the character captures the flag, I automatically reload their character. Is it possible that this may be disrupting the tweenservice?

do you mean

player:LoadCharacter()

yes, i used LoadCharacter() to reload the player’s character if they ever capture the flag.

there is a property in gui’s called resetonspawn (defaulted to true i think), the loadcharacter basically resets the player and could be resetting the gui.

set resetonspawn == false or uncheckmarked

I would imagine other players should be able to see the tweening, consider using the local test function in test tab to help you test functionalities

test

You’re right. I forgot to use that test thing, because I thought it was an issue with the tweenService, but now that i unchecked resetOnSpawn, the tweening works. Thank you.

1 Like