yep, its in the equiponjoin function which works, all i gotta do is change the stringvalue’s value when the player leaves. thats where it fails to do so as it cant find the “aura” folder
In your equipOnJoin function, it does not explicitly state the load the profile data. Which leads me to believe that they are not loading the saved data at all.
no wait lemme explain the function:
local function equipOnJoin(player, char) --this works
local aurafolder = char:WaitForChild("Aura")
local currentaura = player:WaitForChild("CurrentAura")
if currentaura.Value ~= "" then
aurahandler.EquipAura(player, player.Character, game.ReplicatedStorage.Auras[currentaura.Value])
end
end
so basically the saved value is “currentaura” and i need to equip a certain aura which is equal to the saved value.
so then i use the equipaura function which will equip an aura and this aura is actually equal to the saved value (game.ReplicatedStorage.Auras[currentaura.Value]).
so all thats left is to change that value and it will equip the right aura
Apologies, but I am not following with what you’re saying.
so like rn all i need is that it changes the value of “currentaura” (which is done within the saveAura function) so i simply need to call the function right before leaving which is what i cant do
I’m going to be honest I don’t see any code that shows you loading the saved aura from the datastore into the game. You’re essentially just loading the default aura here. I hope you understand that it doesn’t automatically load things for you.
Set currentaura
to the value you saved in the datastore, and then see if that fixes the issue.
nvm i got it working i just had to change it to when a child is added/removed from the aura folder
local function saveAura(player)
local profile = datamanager.Profiles[player]
local aura = player.Character:FindFirstChild("Aura"):FindFirstChildWhichIsA("Folder") --where i get the error
if aura then
profile.Data.CurrentAura = aura.Name
player:FindFirstChild("CurrentAura").Value = profile.Data.CurrentAura
print("Successfully saved the aura "..aura.Name.." to "..player.Name..".")
else
profile.Data.CurrentAura = ""
player:FindFirstChild("CurrentAura").Value = profile.Data.CurrentAura
end
end
local function equipOnJoin(player, char)
local aurafolder = char:WaitForChild("Aura")
local currentaura = player:WaitForChild("CurrentAura")
if currentaura.Value ~= "" then
aurahandler.EquipAura(player, player.Character, game.ReplicatedStorage.Auras[currentaura.Value])
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
equipOnJoin(player, char)
char:WaitForChild("Aura").ChildAdded:Connect(function()
saveAura(player)
end)
char:WaitForChild("Aura").ChildRemoved:Connect(function()
saveAura(player)
end)
end)
end)
anyways thanks y’all for ur help
So best one is findfirstchild? But that also gives me error sometime.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.