So I’m working on a game where I am using a proximity prompt to fire a bindable event in order to change an Int Value in Server Storage. Problem is, well… it’s not updating to the new Value. Here are the scripts.
the bindable is located in game.ServerStorage.Values.CollectedNotebooks
ProximityPrompt Script:
Handler Script:
I have even tried checking for the value every second through a script in Workspace:
local CollectedNotebooks = game.ServerStorage.Values.CollectedNotebooks.Value
while wait(1) do
print(CollectedNotebooks)
end
You cant set the value of an IntValue when you set a variable to the value. local CollectedNotebooks = game.ServerStorage.Values.CollectedNotebooks.Value
Will just be an integer, nothing else.
So the value is not updated in the IntValue.
Update the IntValue’s Value
because when i need to change the int value’s value i do what you said already in the screenshots. I write local CollectedNotebooks = game.ServerStorage.Values.CollectedNotebooks.Value
but it does not work?
local CN = CollectedNotebooks.Value -- this sets CN to the number
CN = CN + 1 -- this adds 1 to CN, but doesn't do anything to CollectedNotebooks.Value
...
local CN = CollectedNotebooks -- this sets CN to CollectedNotebooks
CN.Value = CN.Value + 1 -- this adds 1 to CN.Value
local CollectedNotebooks = game.ServerStorage.Values.CollectedNotebooks
bindable.Event:Connect(function()
local CN = CollectedNotebooks
CN.Value = CN.Value + 1
print(CollectedNotebooks)
if CollectedNotebooks == 10 then
-- Game Over
end
end)```
local int = workspace.Value --> Create a variable to the integer object
while true do
int.Value = int.Value + 1 --> The value of int is being changed, not the variable itself
print(int.Value)
wait(1)
int.Value = 0 --> Reset for test
break
end
local int = workspace.Value.Value --> Becomes a reference to the integer value, not the object
while true do
int = int + 1 -- > Updates the variable
print(int) --> Prints 1
print(workspace.Value.Value) --> Prints 0 as the object has not been changed
wait(1)
break
end
local int = workspace.Value --> Create a variable to the integer object
print(int.Parent) --> Prints Workspace
local int = workspace.Value.Value --> Create a variable to the integer itself
while true do
if int == 10 then
break
else
int = int + 1
end
end
print(int.Parent) --> Throws error, since the variable is an integer not a reference to the object.
print("Success")