Attempt to index string with 'Value'

Hello I get a weird error

while wait (0.1) do
	local Use = script.Parent.Parent.Use.Value
	script.Parent.Text.Value = Use.."/5"
end

The error is

Players.Oldhalit09.PlayerGui.PlacementGui.TextLabel.Set Use:3: attempt to index string with ‘Value’

I tried 3 values: String Value, Int Value, Number Value

Thanks :slight_smile:

Use script.Parent.Text .

3 Likes

Oh thanks :smiley: I’m not careful at all .

2 Likes

Adding to what msix29 said instead of using a while true do loop using something like this:

script.Parent.Parent.Use:GetPropertyChangedSignal("Value"):Connect(function()
    script.Parent.Text = script.Parent.Parent.Use.Value .. "/5"
end)

The way this works is that it will run the code block when the value updates instead of every 1/10th of a second, just a performance booster.

Also if what the user above said worked, please mark that post as a solution.

Edit: I would mark theirs, they solved the problem :sweat_smile: I’m just adding to it.

Ohh, thanks again this will be optimize game(Probably) :smiley:

1 Like

Better yet, you can use the value’s ‘Changed’ event/signal.

local Parent = script.Parent
local Container = Parent.Parent
local Use = Container.Use

local function OnChanged(Value)
	Parent.Text = Value.."/5"
end

Use.Changed:Connect(OnChanged)
1 Like