Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

When value is changed, TextLabel does not update? [WORKS]

I am currently creating a game in which you get coins and these coins are added to a currency value gui on the side of the screen.

I also have a shop in which you can spend your coins but the error comes when you buy an item from the shop.

So if an item costs 5 coins and you have 9 on you, the GUI text does not change to the value which is 4, bit instead it stays at 9.

I am using an IntValue for the value

Here is the code for the Changed function

local change = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui").ImageLabel.IntValue

change.Changed:Connect(function()
	local textLabel = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui").ImageLabel.TextLabel
	textLabel.Text = change.Value
end)

And here is the code for the 5 coins being subtracted from the balance and the item being cloned into the inventory

gravprice.MouseButton1Click:Connect(function()
	if value.Value >= 5 then
	value.Value = value.Value - 5
	local copy = gun:Clone()
	copy.Parent = player.Backpack
	copy.Name = "Gun"
	end
end)

The only help I really need is with updating the textlabel to match the IntValue value, any help is appreciated.

1 comment

0

It works, nevermind.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.