So what I wanted to do is create a data store that holds a string value. with that string value, it clones the Grimoire which belongs to that string value with a string i tried doing this however I get this error
ServerScriptService.ATTACKS.UpdatedAttackScript.GrimoireActivation:16: attempt to call a nil value
Grimoire Activation Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EventFolder = ReplicatedStorage:WaitForChild("EVENTS")
local Remote = EventFolder.ActivateGrimoire
function GetGrimoire(player)
local Char = player.Character
local Hurmp = Char.HumanoidRootPart
local DataFolder = player.Data
local Grimoire = DataFolder.Grimoire
local GrimoireName = Grimoire.Value
if GrimoireName == "None" then
else
warn(GrimoireName)
local GrimoireFolder = script..GrimoireName:Clone()
local NewGrimoire = Grimoire.Open
NewGrimoire.Parent = workspace
end
end
EventFolder.ActivateGrimoire.OnServerEvent:Connect(function(Player)
GetGrimoire(Player)
end)
DataStore
-- Datastore Version 1
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("AA99")
game.Players.PlayerAdded:Connect(function(player)
local datafolder = Instance.new("Folder")
datafolder.Name = "Data"
datafolder.Parent = player
local Grimoire = Instance.new("StringValue")
Grimoire.Name = "Grimoire"
Grimoire.Value = "FireGrimoire"
Grimoire.Parent = datafolder
end)
game.Players.PlayerRemoving:Connect(function(player)
local sucess, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId.."-Grimoire",player.Data.Grimoire.Value)
end)
if sucess then
warn("Data saved")
else
print("Eror Saving Data")
warn(errormessage)
end
end)

1 comment
yeah i forgot about findfirstchild cause i was tired