|
| 17 Apr 2017 04:26 AM |
http://wiki.roblox.com/index.php?title=Saving_Player_Data
followed this above to setup my server script and module script.
Im saving gold and need to update my Custom UI's via local whenever the players gold value changes. However i have no clue how to send request for change from local script or how local script can detect when the value has been changed so it can update the UI. Help please, thanks |
|
|
| Report Abuse |
|
|
|
| 17 Apr 2017 04:30 AM |
:FireClient the server when it changes
|
|
|
| Report Abuse |
|
|
|
| 17 Apr 2017 04:37 AM |
| sorry i said that wrong. Where do i actually edit the gold value? if its in the local script how do i inform the module script of the local script's change request? |
|
|
| Report Abuse |
|
|
|
| 17 Apr 2017 04:39 AM |
You shouldn't let the client change the amount of gold
|
|
|
| Report Abuse |
|
|
|
| 17 Apr 2017 04:47 AM |
| Ok so how do i change their value for gold then? Im really curious and the wiki isnt being very helpful. I also dont want my game to be easily exploited either |
|
|
| Report Abuse |
|
|
|
| 17 Apr 2017 04:48 AM |
when do you want their gold to be changed?
|
|
|
| Report Abuse |
|
|
|
| 17 Apr 2017 04:56 AM |
every two seconds for example like
while true do wait(2) ---Gold Change goes here end |
|
|
| Report Abuse |
|
|
|
| 17 Apr 2017 04:58 AM |
function PlayerStatManager:ChangeStat(player, statName, changeValue) sessionData[player][statName] = sessionData[player][statName] + changeValue end
I have this in my module script that im trying to get to fire. any idea how i can fire this from local script? |
|
|
| Report Abuse |
|
|
| |
|
|
| 17 Apr 2017 05:37 AM |
Alright moved to server script and then learnt about remote functions and tried using it here,
Local Script:
local Type = "Gold" local Val = "10" local Stats = StatsFunction:InvokeServer(Type,Val)
Server Script:
function StatsFunction.OnServerInvoke(Player,Type,Val) PlayerStatManager:ChangeStat(Player, Type, Val) end
function PlayerStatManager:ChangeStat(player, statName, changeValue) sessionData[player][statName] = sessionData[player][statName] + changeValue end
i printed out sessionData[player][statName] and it printed Gold. I realised what its tryna do here is do Gold + 10 which isnt returning a value because of the two different datatypes. Now just have to figure how to access the gold value in server script. It was so easy when i could just do Gold.Value with intValues lol |
|
|
| Report Abuse |
|
|