Cannot add values

Hi! I am having trouble with this one piece of code:

Trigger.OnClientEvent:Connect(function()
	Tween(game.Workspace.CurrentCamera, MainCam)
	NPCName.Text = NPC.Name
	typeMessage("Test", 1)
	wait(1)
	Choices:TweenPosition(UDim2.new(0.56, 0, 0.399, 0))
	typeMessage("...", 0.25)
	ChoiceValue.Value = ChoiceValue.Value + 1
end)

The main concern is in the last line of code, basically it will not add the number in the value. Pretty confused since I also have been doing this NumberValue thing on other stuff and it works. The code is inside a LocalScript. Thank you in advance for helping!

2 Likes

Are you getting the prints in the output window?

things on the client (made by local scripts) do not replicated to the server and aren’t detected by server scripts (normal scripts).

3 Likes

Well the rest of the code works, just the Adding Value is what isn’t working

Did u check the client value? also is ChoiceValue a part smthing or a value?

1 Like

ChoiceValue is a NumberValue, and I’ve also checked the client value as well, not adding :confused:

1 Like

Try this instead:

ChoiceValue.Value += 1

2 Likes

Try this out:

Trigger.OnClientEvent:Connect(function()
	Tween(game.Workspace.CurrentCamera, MainCam)
	NPCName.Text = NPC.Name
	typeMessage("Test", 1)
	wait(1)
	Choices:TweenPosition(UDim2.new(0.56, 0, 0.399, 0))
	typeMessage("...", 0.25)
	warn("old: ", ChoiceValue.Value)
	ChoiceValue.Value += 1
	warn("new: ", ChoiceValue.Value)
end)
2 Likes

Didn’t change the number, still the same

2 Likes

What they wrote wasn’t suppose to change the number to my knowledge.

But have you tried my answer?
Try Value += 1

1 Like

So both prints gave out the same value? That’s pretty weird.

1 Like

Is there any errors in the output?

1 Like

That’s not what I mean, the thing printed out different numbers, but the value is just the same (0)

2 Likes

its probably this never returning back to this script put the value above it and see if it works or put a print right above this and see if it prints

1 Like

I put the value above, nothing still.

1 Like

then its not making it done to it you need to put prints through it until you find where its stopping or if its even working at all
maybe the first textmessage call

try above it with a print
then one after

might even be that tween function not returning

1 Like

Where are you getting this from? Are you trying to check the value of the number on the server?

1 Like

both printed aaaaaa. idk what to dooo

1 Like

I’m tyring to change the number by adding a number to the value, hence

ChoiceValue.Value += 1

Yet it still doesn’t work??

1 Like

So the 'warn()'s gave different numbers, right?

Now I ask you this, where did you get this?