Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 20 Aug 2013 07:52 PM |
Ok, I am making assignable hotkeys for player's to use in my game for skills.
First , would this script successfully convert the text boxes' text to the MyString's value?:
script.Parent.Parent.Changed:connect(function(Property) if Property ~= "Text" then return end script.Parent.MyString.Value = script.Parent.Text end)
Second, how would I save the text/MyString using Data Persistence? Would this work? It is inside of MyString?
game.Players.PlayerAdded:connect(function(player) player:WaitForDataReady() savedString = player:LoadString("MyString") player.MyString.Value = saveString end)
game.Players.PlayerRemoving:connect(function(player) if player:WaitForDataReady() then player:SaveString("MyString",script.Parent.MyString.Value) end end) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Aug 2013 07:53 PM |
NEVER save data when a player leaves. Also, it should work, testing is the best form of testing |
|
|
| Report Abuse |
|
|
qdhxx
|
  |
| Joined: 02 Jul 2010 |
| Total Posts: 56658 |
|
|
| 20 Aug 2013 07:54 PM |
I read it as "toast ring"
im hungry
|
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 20 Aug 2013 08:02 PM |
If I shouldn't save the data when the players leaves, I should add a save button for when it is clicked, the string saves. Would it go like this?
local player = game.Players.LocalPlayer script.Parent.MouseButton1Down:connect(function() if player:WaitForDataReady() then player:SaveString("MyString", player.PlayerGui["Assign Hotkeys"].FlashBox.MyString.Value) end end) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Aug 2013 08:05 PM |
| Either Save button or Changed function (auto-save) |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 20 Aug 2013 08:06 PM |
| So I wrote the script above correctly? :D |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Aug 2013 08:09 PM |
Most likely, it seems fine. But why do you need the if? You can just do: player:WaitForDataReady() |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 20 Aug 2013 08:13 PM |
And this is wrong right?
script.Parent.Parent.Changed:connect(function(Property) if Property ~= "Text" then return end script.Parent.MyString.Value = script.Parent.Text end)
Because I would want to text convert to the string so the string can be saved. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Aug 2013 08:15 PM |
Player::SaveString(Name, Value) tostring can will convert it to a string.
Other than that, I don't understand what you want |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 20 Aug 2013 08:16 PM |
| I want the player to be able to assign a key to a skill. Then save, and when they come back in game their key will still be there. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Aug 2013 08:17 PM |
I would make all the keys and it's functions in a string value, like:
StringValue Name: "Shortcut" Value: "Shortcut Key" -Script for when they click "Shortcut Key"
i g2g, you get the point |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
| |
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 20 Aug 2013 08:46 PM |
| Bump, I honestly don't understand, all I want to do is save a string. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Aug 2013 08:46 PM |
| Player::SaveString(Name, Value) |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 20 Aug 2013 08:48 PM |
| But I tried that and it didn't work. D: |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 20 Aug 2013 08:48 PM |
| You are doing something wrong |
|
|
| Report Abuse |
|
|
Kasumo
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 2467 |
|
|
| 20 Aug 2013 08:56 PM |
I will give you all the details and create a template right here.
StarterGui>Assign Hotkeys> BG>FlashBox
FlashBox is a text box. Inside of FlashBox I have a StringValue named 'MyString', a script, and a local script.
1) The code inside of script is:
script.Parent.Parent.Changed:connect(function(Property) if Property ~= "Text" then return end script.Parent.Text = tostring(script.Parent.MyString.Value) end)
I used this so that any text that goes into 'FlashBox' turns into 'MyString' value. Thus making 'MyString' savable.
2) I have no string value inside of 'MyString', because what the string will be is based on what the player enter's inside of 'FlashBox'
3)The code inside of local script is:
The skill function.
Now, where would I insert a script to save and load 'MyString' value?
|
|
|
| Report Abuse |
|
|