Script not recognizing text change

Hi, I want to make it so that when the player uses the stage transfer, there is a limited amount of steps the player can use. I’ve got it working except its not changing the steps amount. Can someone help? Thanks.

Here is my current code:

local player = game.Players.LocalPlayer
local Humanoid = player.Character:WaitForChild("Humanoid")
local steps = player.PlayerGui.StepsGUI.Frame.TextLabel
local stagetrans = player.PlayerGui.StageTransfer.CurrentStage
print(steps.Text)

stagetrans:GetPropertyChangedSignal("Text"):Connect(function()
	if stagetrans.Text == 0 then
		steps.Text = 9999999
	elseif stagetrans.Text == 1 then
		steps.Text = 100
	elseif stagetrans.Text == 2 then
		steps.Text = 50
	end
end)

while task.wait(.1) do
	if Humanoid.MoveDirection ~= Vector3.new(0, 0, 0) then
		local new = tonumber(steps.Text)-1
		local text = tostring(new)
		player.PlayerGui.StepsGUI.Frame.TextLabel.Text = text
		if new == 0 then
			Humanoid.Health -=100
		elseif new <= 50 then
			steps.TextColor3 = Color3.new(0.866667, 0, 0.0156863)
			steps.Parent.ImageLabel.ImageColor3 = Color3.new(0.866667, 0, 0.0156863)
		end
	end
end

You are comparing a string to a number…those are never going to be equal.

Also, you don’t need to make a new topic just because your old one didn’t get a response in 10 minutes.

1 Like

local player = game.Players.LocalPlayer
local Humanoid = player.Character:WaitForChild("Humanoid")
local steps = player.PlayerGui.StepsGUI.Frame.TextLabel
local stagetrans = player.PlayerGui.StageTransfer.CurrentStage
print(steps.Text)

stagetrans:GetPropertyChangedSignal("Text"):Connect(function()
	if stagetrans.Text == “0” then
		steps.Text = “9999999”
	elseif stagetrans.Text == “1” then
		steps.Text = “100”
	elseif stagetrans.Text == “2” then
		steps.Text = “50”
	end
end)

while task.wait(.1) do
	if Humanoid.MoveDirection ~= Vector3.new(0, 0, 0) then
		local new = tonumber(steps.Text)-1
		local text = tostring(new)
		player.PlayerGui.StepsGUI.Frame.TextLabel.Text = text
		if new == 0 then
			Humanoid.Health -=100
		elseif new <= 50 then
			steps.TextColor3 = Color3.new(0.866667, 0, 0.0156863)
			steps.Parent.ImageLabel.ImageColor3 = Color3.new(0.866667, 0, 0.0156863)
		end
	end
end

1 Like

It was kind of urgent I don’t usually do that.

It works! Thank you so much! :DD

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.