I have this LocalScript that saves the values from a player into a folder so I can save them later. However, the script isn’t working and there are no errors. It’s not detecting when the value gets changed.
LocalScript:
local Player = game.Players.LocalPlayer
local PlayerStats = game.ReplicatedStorage:WaitForChild(Player.Name)
local Cash = Player:WaitForChild("leaderstats").Cash
local RPName = Player:WaitForChild("RPName")
local RPBio = Player:WaitForChild("RPBio")
local CnB = Player:WaitForChild("CashInBank")
function Changed(name, instance)
PlayerStats:FindFirstChild(name).Value = instance.Value
end
Cash:GetPropertyChangedSignal("Value"):Connect(function()
print("Got Cash")
Changed("Cash",Cash)
end)
RPName:GetPropertyChangedSignal("Value"):Connect(function()
print("Changed Name")
Changed("RPName",RPName)
end)
RPBio:GetPropertyChangedSignal("Value"):Connect(function()
print("Changed Bio")
Changed("RPBio",RPBio)
end)
CnB:GetPropertyChangedSignal("Value"):Connect(function()
print("Change in Bank")
Changed("CashInBank",CnB)
end)
The script looks like it should work, where is the localscript located?
And are you getting an Infinite Yield warnings?
It’s located in the StarterPlayer. I’m not getting any warnings either.
Put it in StarterPlayerScripts?
Also this is only going to change them locally, if you want them to detect and then change on the server, use a RemoteEvent for changing the value
The thing you do is only valid for the client. The server is unable to see that changes.
I already tried it in StarterPlayerScripts.
TIME FOR PRINTING.MOV
local Player = game.Players.LocalPlayer
local PlayerStats = game.ReplicatedStorage:WaitForChild(Player.Name)
local Cash = Player:WaitForChild("leaderstats").Cash
local RPName = Player:WaitForChild("RPName")
local RPBio = Player:WaitForChild("RPBio")
local CnB = Player:WaitForChild("CashInBank")
print("Variables loaded")
function Changed(name, instance)
print("Changed")
PlayerStats:FindFirstChild(name).Value = instance.Value
end
Cash:GetPropertyChangedSignal("Value"):Connect(function()
print("Got Cash")
Changed("Cash",Cash)
end)
RPName:GetPropertyChangedSignal("Value"):Connect(function()
print("Changed Name")
Changed("RPName",RPName)
end)
RPBio:GetPropertyChangedSignal("Value"):Connect(function()
print("Changed Bio")
Changed("RPBio",RPBio)
end)
CnB:GetPropertyChangedSignal("Value"):Connect(function()
print("Change in Bank")
Changed("CashInBank",CnB)
end)
print("Ending the script here")
Do any of the prints work or they also don’t work?
The prints do not work at all.
Okay try doing an outside print like @JackscarIitt did. If those print, then something is up with how you’re trying to change the valyes
Nothing printed when I tried it.
Ok wut how
If nothing printed, then chances are it’s having to do with the script itself
Are you sure that the Disabled
property isn’t set to true? If not, can you add a print way before you first define your variables?
The script isn’t disabled and it didn’t print what I put at the top.
Impossible
The only thing that I can think is sending a image of your Explorer, and are you double sure that you’re getting every Output that’s being received? Such as Warnings, Errors, Prints, etc
Yes, I am receiving all output messages.
Explorer:
Try replacing the GetPropertyChangedSignal
Events with the Changed
Event instead?
1 Like
Move the script to StarterPlayerScripts and see if that works
Only other thing I’d suggest then is sending a place file, cause this should work regardless unless if for some reason you’re destroying the Values after the WaitForChild()
functions are called
Show a image of the output because I just tried the script in studio and it is printing fine.