✓ Accepted answer
Updated with 2 new scripts to do what you ask! :)
Code Server script:
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local ChageIDFunction_Name = "ChangePlayer_Value_Funtion"
Players.PlayerAdded:Connect(function(player)
local PlayerList = (function() local F = RS:FindFirstChild("PlayerList") if(F == nil) then F = Instance.new("Folder",RS) F.Name = "PlayerList" end return F end)()
local ChangeIDFunct = (function()
local FunctFdr = RS:FindFirstChild("RemoteFunctions")
if(FunctFdr == nil) then
FunctFdr = Instance.new("Folder",RS)
FunctFdr.Name = "RemoteFunctions"
end
local Funct = FunctFdr:FindFirstChild(ChageIDFunction_Name)
if(Funct == nil) then
Funct = Instance.new("RemoteFunction",FunctFdr)
Funct.Name = ChageIDFunction_Name
end
return Funct
end)()
ChangeIDFunct.OnServerInvoke = (function(player,value)
local PlayerId = player.UserId
local Chk = PlayerList:FindFirstChild(PlayerId)
if(Chk ~= nil) then
Chk.Value = value
end
end)
local playerid = Instance.new("NumberValue", PlayerList)
playerid.Name = player.UserId
playerid.Value = 0
end)
Local Script: (Note when you run this code it will continually add on 1 to the current value you have stored in your playerid value!)
Code:
local RS = game:GetService("ReplicatedStorage")
local PlayerList_Folder = RS:WaitForChild("PlayerList",5)
local RemoteFunctions_Folder = RS:WaitForChild("RemoteFunctions",5)
local Player = game.Players.LocalPlayer
local MyId = Player.UserId
local Chk = PlayerList_Folder:WaitForChild(MyId,5)
local ChangePlayerIDValueFunct = RemoteFunctions_Folder:WaitForChild("ChangePlayer_Value_Funtion",5)
while true do
if(Chk ~= nil) then
print("Found IT!!! \n MyId is [",MyId,"] and the stored value is [",Chk.Value,"]" )
else
print("Nothings there... sleeping!")
wait(1)
end
ChangePlayerIDValueFunct:InvokeServer(Chk.Value+1)
wait()
end
Obviously you would hook up the ChangePlayerIDValueFunct:InvokeServer() inside a button or something that changed when you did an action kinda like adding to a score board etc...
Hope this helps! :)
5 comments
I appeciate your help but sadly I get "attempt to index number with 'Value'" when I place it in my local script.
I just ran a test to see if I can change the value via a local script and I cannot, so now I have to try something else. :( Once again, thank you for your help though, I appeciate it.
Hmm.. ill see what i can come up with. Just working on an example that might work. If/when it works ill update my answer with the new code :)
Just updated the answer with a working script though its not tested for online use. it Should work as its using a remote function but not 100% sure"
@TGazza THANK YOU SO MUCH! It works perfectly! Thank you so much, I deeply appeciate your help!! :D