Can't change number value from a tool?

I’m trying to make a script within a tool change a variable outside of the tool in the workspace
The script is not changing the variable and I am not getting any error output on the output ui of studio. The tool is working and is being activated, as the print function in the script is working properly but still the variable does absolutely nothimg.

I could not find any solution on YouTube or the internet and I have no idea what to do.

Here is an example of the script in the tool:

local value = game.Workspace.cloner.Ture.Value
local Tool = script.Parent;


enabled = true
function onActivated()
	if not enabled  then
		return
	end

	enabled = false
	print("Tool activated")
	value = 1
	
	
	enabled = true     
end	

function onEquipped()
    print("Tool equipped")
			
end

script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)

thanks for reading! <3

Is this a Script or a LocalScript?
Also, is the goal of the script to ADD one to the value each time that it is activated, or just to SET the value to one?

Don’t define value as game.Workspace.cloner.Ture.Value, instead try this:

local Ture = workspace.cloner.Ture
local Tool = script.Parent

enabled = true
function onActivated()
	if not enabled  then
		return
	end

	enabled = false
	print("Tool activated")
	Ture.Value = 1
	
	
	enabled = true     
end	

function onEquipped()
    print("Tool equipped")
			
end

script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)

If this is a Script, (not a LocalScript), then the Ture.Changed event should fire on the server.

1 Like
local Ture = game.Workspace.cloner.Ture
local Tool = script.Parent;
local enabled = true

function onActivated()
	if not enabled  then
		return
	end
	enabled = false
	print("Tool activated")
	Ture.Value = 1
	enabled = true     
end	

function onEquipped()
	print("Tool equipped")
end

script.Parent.Activated:connect(onActivated)

local value = game.Workspace.cloner.Ture.Value this just gets the value of the “Value” property of the instance named “Ture” and assigns it to the variable named “value”, when you later assign 1 to “value” you’re not assigning it to the “Value” property of the instance named “Ture” you’re just overriding the existing value stored inside value.

1 Like

Thanks! I was pretty confused and this makes more sense now.