Okay but where do I put it? Sorry if it may sound obvious but datastores are usually hard for me lol
In a serverscript. Serverscriptservice
Ofcourse, just read the extra step to find out how to save enums.
No, I mean where do I put the BackgroundColor3 inside the script?
Infront of .Frame
Yeah but that was for materials. How would I do it for keycodes?
You could just do the same but enum.KeyCode.
So when instead of doing
game:GetService("DataStoreService"):GetDataStore("material"):SetAsync("ilikeplastic",typeof(part.Material))
I do
game:GetService("DataStoreService"):GetDataStore("material"):SetAsync("ilikeplastic",typeof(enum.keycode))
Yes, just put the argument in Enum.KeyCode. and it should successfully save
So like
typeof(Enum.KeyCode.V)
Sorry for the trouble.
Yes, and to load read further.
Alright. Thanks! Sorry for the trouble.
Would I be able to use a variable for this?
Like for example
local keycode = Enum.KeyCode.V
game:GetService("DataStoreService"):GetDataStore("material"):SetAsync("ilikeplastic",typeof(Keycode))
Sorry to keep bugging you.
yeah, obviously, there’s no trouble dw
I really really hate to bug you again. But I’m having some issues. I keep getting this error:
EnumItem is not a valid member of “Enum.KeyCode”
This is the code that’s throwing this error:
keycode = Enum.KeyCode[game:GetService("DataStoreService"):GetDataStore("material"):GetAsync("ilikeplastic")]
I tested what typeof(Enum.KeyCode.V) prints and it just prints “EnumItem”
So so so sorry to bug you again
Try to string instead? I’ll change tutorial if that’s the issue
Tostring the enum keycode
For some reason tostring() didn’t work either. What I had to do was this:
game:GetService("DataStoreService"):GetDataStore("material"):SetAsync("ilikeplastic", "V")
keycode = Enum.KeyCode[game:GetService("DataStoreService"):GetDataStore("material"):GetAsync("ilikeplastic") or "V"]
And what I’m doing is putting them in PlayerAdded and PlayerRemoving events but when I change the Keycode Variable and the leave the game to save it, it throws an error. Here is my code:
local keycode = "V"
local DB = false
game.Players.PlayerRemoving:Connect(function()
game:GetService("DataStoreService"):GetDataStore("material"):SetAsync("ilikeplastic", keycode)
print(keycode)
end)
game.Workspace.Part.Touched:Connect(function()
if DB == false then
DB = true
keycode = "C"
end
end)
game.Players.PlayerAdded:Connect(function()
keycode = Enum.KeyCode[game:GetService("DataStoreService"):GetDataStore("material"):GetAsync("ilikeplastic") or "V"]
print(keycode)
end)
Error: 104: Cannot store token in data store. Data stores can only accept valid UTF-8 characters.
But aren’t strings UTF-8 values?
Sorry
I’ll just write a working keycode system later. I’m busy
I am so sorry. I didn’t mean to cause any trouble. But thanks.