GetPropertyChangedSignal only calling once and how to make these tweens work?

I have two tweens in a script, one tween that makes the star moves from checkpoint to checkpoint using a GetPropertyChangedSignal event and then another one that allows the star to float.

What I want is that when the player hops to another checkpoint, the float tween pauses until the other tween plays out and allows the start to move to the next checkpoint.

Another problem that I have is that the GetPropertyChangedSignal fires only once for some weird reason, I don’t have much experience with it so I believe I am using it wrong :disappointed:

Here is the script:

local arrow = ReplicatedStorage:WaitForChild("Arrow")
local TweenService = game:GetService("TweenService")



local player = game.Players.LocalPlayer
local cloneStar = workspace:WaitForChild("Star")
print("Connected")


local level = player:WaitForChild("leaderstats").Level.Value
local checkpoints = game.Workspace.Checkpoints:FindFirstChild(level)
print("Leaderstats found")


local play = true
print("on")


checkpoints:GetPropertyChangedSignal("Name")
print("on")
play = false


if cloneStar ~= nil then
	if game.Workspace.Checkpoints:FindFirstChild(level + 1) then
		local ls = game.Workspace.Checkpoints:FindFirstChild(level + 1)


		if cloneStar.PrimaryPart then
			local tweenInfo = TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,1,false,0)


			local NewPosition = {CFrame = ls.CFrame + Vector3.new(0,13.5,0)}


			local tween = TweenService:Create(cloneStar.PrimaryPart, tweenInfo, NewPosition)		


			tween:Play()
			print("Level changed to"..checkpoints.Name)


			tween.Completed:Wait()


			play = true			
			print("Tween completed")
		end


	end


end


			
local tweenInfo2 = TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,-1,true,0 )	

					
local FloatPosition = { Position = cloneStar.PrimaryPart.Position + Vector3.new(0,3,0)}
					
						
local tween2 = TweenService:Create(cloneStar.PrimaryPart, tweenInfo2, FloatPosition)	


if play == false then		
	tween2:Cancel()		
	print("Tween paused")	
else		
	if play == true then
		tween2:Play()	
		print ("Tween playing")		
	end

end
2 Likes

I think this thread should answer your problem with the GetPropertyChangedSignal working only once: Need help with GetPropertyChangedSignal - #7 by WingItMan

If you want to pause a tween, you can use the tween:Pause()

1 Like

So should I use RunService instead?? And I tried using pause already, might add it back.

Frm what I could tell I believe you did the GetPropertyChangedSignal incorrectly as it is an event so it needs a connection. Inorder to properly use it, you do in your case

checkpoints:GetPropertyChangedSignal("Name"):Connect(function()
    -- Code here for when the Name property changes
end)

Basically replace how you tried it with mine and add the code that is needed to run when the property changes in that code. This is probably why it’s only working once, nothing is connected to an event

2 Likes

Hmm. I’m sure about using RunService. I just thought that thread might have shown where the problem was. It seems that wasn’t the issue as @EmbatTheHybrid pointed out that the function isn’t connected to an event. Since you have already used tween:Pause(), could you explain what the issue was while using it?

Not really because I am changing the "Name property of the checkpoints. Nothing physics related but when I used tween:Pause(), the GetPropertyChangedSignal still wasn’t working so I changed it to see if that was the problem.

Tried this already and the GetPropertyChangedSignal wasn’t working at all, it didn’t even activate once.

Is the checkpoints trying to find a part with the same name as the value of level or a value?

Saw this on the thread:

Blockquote Both .Changed and :GetPropertyChangedSignal() don’t fire when variables are updated by physics. This includes movement variables like CFrame, Position and Rotation in your case. Instead people use RunService.Stepped:Connect() for this. (From what I’ve read and experienced myself)

Maybe the reason is because of the tween using CFrame within it??

As the value of the player’s leaderstats.

That wouldn’t be the case as you’re trying to see if Name is changed, nothing related to movement or rotation. And what does the checkpoints folder contain, parts?

Oh, just making sure and the checkpoints is a model in workspace, containing UnionOperations named 1, 2,3, 4.

Does anything even change the name of the part that’s in the checkpoints variable? If nothing happened then the name never changed. Which would make sense, why would checkpoint 2 be changed to checkpoint 3 for example. It will only run the code is the name of the checkpoint you made it find is changed

Makes sense, I was hoping that it would change to the player’s leaderstats, but should I use the leaderstats instead because the part in the checkpoints variable change the leaderstats.

I was actually researching it a bit to see how could I use the leaderstats with GetPropertyChagedSignal.

What you could do instead is use the changed event of the level value in leaderstats to detect when it’s changed. The benefit of that as well is that gives you a parameter that contains the new val it was changed to

Quick question, do I type level or level.Value??

Depends on what you’re trying to do

Just tryna get the changed value of the leaderstats. If I use level.Changed, it attempts to index nil with 'Connect" and if I use level.Value.Changed, it attempts to index nil with ‘Changed’

That’s because in your case, the level variable is set to the value of the Level value in leaderstats, remove the .Value from player:waitForChild("leaderstats").Level.Value

Now I am getting Attempt to index nil with ‘Connect’