Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

I don't understand Why I am getting errors?

Asked by 10 years ago
labelWood = script.Parent.labelWood
labelIron = script.Parent.labelIron
labelPlanks = script.Parent.labelPlanks
labelStone = script.Parent.labelStone

local valueWood = script.Parent.Values.valueWood.Value
local valueIron = script.Parent.Values.valueIron.Value
local valuePlanks = script.Parent.Values.valuePlanks.Value
local valueStone = script.Parent.Values.valueStone.Value

valueWood.Changed:connect(function()
    labelWood.Text = "Wood:" valueWood ""
    wait()
end)
valueIron.Changed:connect(function()
    labelIron.Text = "Iron:" valueIron ""
    wait()
end)
valuePlanks.Changed:connect(function()
    labelPlanks.Text = "Planks:" valuePlanks ""
    wait()
end)
valueStone.Changed:connect(function()
    labelStone.Text = "Stone:" valueStone ""
    wait()
end)

It is meant to be basic, but it makes no sense as to why it is givving me an error as soon as it starts the valueWood function on Line 11. Any and all help is greatly appreciated as I need to finish this game soon.

1 answer

Log in to vote
1
Answered by
iaz3 190
10 years ago

That is not how you concentrate strings together. For future reference, provide details as to what the error IS, not just saying it doesn't work and you don't know why.

Also, ALL your variables are the VALUE, they will NEVER change, and they do not have the .Changed event. Ever.

labelWood = script.Parent.labelWood
labelIron = script.Parent.labelIron
labelPlanks = script.Parent.labelPlanks
labelStone = script.Parent.labelStone

local valueWood = script.Parent.Values.valueWood
local valueIron = script.Parent.Values.valueIron
local valuePlanks = script.Parent.Values.valuePlanks
local valueStone = script.Parent.Values.valueStone

valueWood.Changed:connect(function()
    labelWood.Text = "Wood: " ..  valueWood.Value
    wait()
end)
valueIron.Changed:connect(function()
    labelIron.Text = "Iron: " .. valueIron.Value
    wait()
end)
valuePlanks.Changed:connect(function()
    labelPlanks.Text = "Planks: " .. valuePlanks.Value
    wait()
end)
valueStone.Changed:connect(function()
    labelStone.Text = "Stone: " .. valueStone.Value
    wait()
end)

The above should work.

Ad

Answer this question