Adding multiple string values with a script

I need to make the empty string value add a string into it when a player clicks it but i have no idea how to. Basically after 3 clicks it should go from no value to Scroom,Scroom,Scroom (ignore the char variable)


local value = game.Workspace.cauldron.Value

button.MouseClick:Connect(function(player)

local char = player.Character

value = value + "Scroom"

end)

Use this instead:

local cauldron = game.Workspace.cauldron
-- later:
cauldron.Value = cauldron.Value .. ",Scroom"

Your other code didn’t work because, you set a variable to the property of an instance. Changing the variable does not also change the instance property.

It also didn’t work because you can’t combine strings with +, use .. for this.

1 Like

What do the 2 dots mean? The value? If so how can i refrence a value that is empty?

.. is used for concatenation (combine strings), + is used for math!

1 Like

Okay sorry for bothering now another question.
How do i make the clickdetector react to the character clicking with diffrent tools?
This is what i have right now how it works is i click the cauldron first then i pull out the tool and it dissapears adding the value but how i intend it to be is pulling out the tool and then clicking the cauldron with the tool in hand removing the tool and adding the value but i cant even click when holding the tool.

	local char = player.Character
	local scroom = char:WaitForChild("Scroom")
	if scroom then
		value.Value = value.Value ..",Scroom"
        scroom:Destroy()
	end
end)```

Something like this?

local cauldron = workspace.cauldron

local function isIngredient(tool)
    if not tool then return false end
    if ? then return true end -- Add a condition to determine if held tool is an ingredient, or it will error
end

button.MouseClick:Connect(function(player)
    local ingredient = player.Character:FindFirstChildOfClass("Tool")
    if isIngredient(ingredient) then
        local name = ingredient.Name
        ingredient:Destory()
        cauldron.Value = cauldron.Value .. "|" .. name
    end
end)

No i mean’t that i wanted the player to be able to click the cauldron while holding the tool and after that my code happens right now its backwards i click the cauldron then pull out the tool.
(heres a gif of what system im trying to recreate https://gyazo.com/a4fa6719980824c7be0dc181007469da)