Number Value not changing

Hey all,
So I am receiving numbers from a client script and that all works. I want number values in replicated storage to say the correct new value. The output from the print is correct but nothing is changing when I go onto the server and also another script doesn’t detect it. Any ideas? Thanks

local rs = game:GetService("ReplicatedStorage")
local events = rs:WaitForChild("Events")
local voting = rs:WaitForChild("Voting")
local megVal = voting:WaitForChild("Megladon").Value
local normVal = voting:WaitForChild("Normal").Value
local viralVal = voting:WaitForChild("Viral").Value


events.VotingChangeRE.OnServerEvent:Connect(function(plr, meg, normal, viral)
	megVal += meg
	normVal += normal
	viralVal += viral
	print("Meg val:"..megVal.. ", Normal val:"..normVal..", Viral val:".. viralVal)
end)
1 Like

I see people say we should not call Value in local like how you did.
Instead we just call its name value like this

local megVal = voting:WaitForChild("Megaldon")

events.VotingChangeRE.OnServerEvent:Connect(function(plr, meg, normal, viral)
megVal.Value += meg
end)
1 Like

Just a bit of clarification-- the problem here is that you can’t store a reference to an instance’s property inside of a variable. That can only be done with the whole instance or tables. That’s why tienke’s solution will fix your issue.

2 Likes

Yeah thanks bro. I think I have done that before aswell and hopefully it never happens again. Much appreciated

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.