Why isn't this Text updating?

Hi there,

I’ve got this script that fires an Event and makes a Value true/false and for some reason the Text isn’t changing even tho the Values are changing in the Output?

Local Script:

main.Blocks.MouseButton1Down:Connect(function()
if requirement.Value >= 50 then
buysound:Play()
equipbutton.Visible = true
blocksequip()
elseif requirement.Value < 50 then errorsound:Play()
if player:WaitForChild(“KillEffects”).Blocks then print(“Owned”)
if player:WaitForChild(“KillEffects”).Blocks.Value == true then
equipbutton.Text = “Unequip”
if player.KillEffects:WaitForChild(“Blocks”).Value == false then
equipbutton.Text = “Equip”
buysound:Play()
blocksequip()
end
end
end
end
end)

Thanks,

2 Likes

Can you show Player Variable, It can be the problem.

local player = game:GetService(“Players”).LocalPlayer

First of all, use ``` to make your code more readable (put them before the code and after). And I think the problem is you changing the text when you don’t have enough requested value (remove end and place it after errorsound:Play())

Can you show the player In game

So, what exactly is main.Blocks?

Oh ok i got where the problem is, I fixed your script. Try this out -

local player = game.Players.LocalPlayer

main.Blocks.MouseButton1Down:Connect(function()
local Blocks = player:WaitForChild("KillEffects").Blocks
if requirement.Value >= 50 then
buysound:Play()
equipbutton.Visible = true
blocksequip()
elseif requirement.Value < 50 then errorsound:Play()
if Blocks then print(“Owned”)
if Blocks.Value == true then
equipbutton.Text = “Unequip”
if Blocks.Value == false then
equipbutton.Text = “Equip”
buysound:Play()
blocksequip()
end
end
end
end
end)

Be sure to let me know if it works.

I get the same thing as my script, Prints true/false in output but the Text doesn’t change still

Is your requirements value less than 50? Because the text changing if then statements are inside the else if statement. If you dont want it to be there than just put an end after the error sound is played and remove an end from the last few lines of the script

The text has to be a set variable before you changing it, it’s related to how the Text property is stored.

local thetext = "mytext"
   .Text = thetext

for numbers, use:

tostring(value)

To verify if Blocks exists, use:

local Blocks = KillEffects.FindFirstChild("Blocks")
if Blocks then