Right now I’m setting player attributes to their character when it spawns. This includes things like their active skillset. However, when they respawn I’m getting the wrong values when I call GetAttribute().
Here is my script when the player spawns (in ServerScriptService):
function setAttributes(character)
if character then
local player = Players:GetPlayerFromCharacter(character)
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
character:SetAttribute("State", "Idle")
character:SetAttribute("Stunned", false)
character:SetAttribute("Iframes", false)
character:SetAttribute("inCombat", false)
character:SetAttribute("lastHitTime", 0)
character:SetAttribute("Skillset", Profiles[player].Data.Skillset)
print("set the skillset attrribute as "..Profiles[player].Data.Skillset)
character:SetAttribute("Sub_Skillset", "Awakening")
character:SetAttribute("FunctionID", nil)
end
end
end
And here is my script to activate a move based on the skillset (just the part receiving the attribute tho; in StartPlayerScripts):
local function onCharacterAdded()
Skillset = Functions.WaitForAttribute(Character, "Skillset") or nil
print(Skillset)
print(Character:GetAttribute("Skillset"))
end
The above function WaitForAttribute() is just in a module script that continually waits for the attribute to not be nil and return the value. Just to wait until server actually assigns the attributes. I have the second and normal GetAttribute() because I thought maybe the above one was causing an issue.
I also have a script just continually checking what the attributes are for this debugging purpose.
Here is the console output:
17:24:30.673 set the skillset attrribute as Itadori - Server - Main:36
17:24:30.712 -------------------CHARACTER SPAWNED----------------- - Client - LocalScript:4
17:24:30.714 Gojo - Client - KeyInput:31
17:24:30.715 Gojo - Client - KeyInput:32
17:24:30.715 {} - Client - KeyInput:35
17:24:30.727 ▼ {
["Iframes"] = false,
["Skillset"] = "Itadori",
["State"] = "Idle",
["Stunned"] = false,
["Sub_Skillset"] = "Awakening",
["inCombat"] = false,
["lastHitTime"] = 0
} - Client - LocalScript:9
As you can see the localscript is getting “Gojo” while it was actually assigned as Itadori. The skillset was Gojo before the player reset, and now it is Itadori, but the localscript still thinks its Gojo. Also, attributes reset when the player resets because it is on their character model, so I have no idea why it’s still Gojo.