Values and references
You are assuming that PS is a reference to the Value property. This is not the case. When the Value property changes, PS will not change, and if you change PS, the Value will not update accordingly.
What you must do is just make PS refer to the IntValue/NumberValue object directly, and directly access the Value property.
References
It is important to know the difference between a value and a reference.
You can think of references as holding some memory location.
In Lua, for example, functions are passed by reference.
Here is some code to demonstrate this:
local fn1, fn2, fn1ref;
fn1 = function()
for i = 1, 12 do
print(i^(1/3));
end
end
fn2 = function()
for i = 1, 12 do
print(i^(1/3));
end
end
fn1ref = fn1;
print(fn1 == fn1ref, rawequal(fn1, fn1ref));
print(fn1 == fn2, rawequal(fn1, fn2));
fn1 and fn1ref contain the same exact function in memory. fn2 is different despite the code, line count, ect, being the same*
Values
Datatypes such as booleans and strings for example, are passed by value, and here is some code to demonstrate how this works:
local bool = false;
local bool2 = bool;
bool = true;
print(bool, bool2);
The variables have different memory allocation, and thus the modification of bool did not modify bool2.
Applying this knowledge into your code, and more
First off, your code is not so good. Your identifiers (variable names, table keys, ect) are misleading.
P is not clear at all, Play can be misleading, player is actually referring to the `Players` service.
Let's clean that portion up.
It might also be a good idea to handle this server side if you have not already. Also don't use a while loop to check if a property changes. Listen for the Changed event instead.
local currentValue = player.PlayerStats.CurrentValue;
currentValue.Changed:Connect(function(newValue)
if (newValue >= 20) then
player.Character.Humanoid.JumpPower = 100;
end
end);
1 comment
Play.Humanoid.JumpPower = Play.Humanoid.JumpPower + PS?