I am doing a Kill for XP script and it seems that this code will not work from lines 21 to 26.
local DS = game:GetService("DataStoreService") local XPStore = DS:GetOrderedDataStore("XP") game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder", player) leaderstats.Name = "leaderstats" local XP = Instance.new("IntValue", leaderstats) XP.Name = "XP" pcall(function() local XPVal = XPStore:GetAsync(player.UserId) if XPVal then XP.Value = XPVal end end) player.CharacterAdded:Connect(function(Character) local humanoid = Character:FindFirstChild("Humanoid") if humanoid then if humanoid.RigType == Enum.humanoid.HumanoidRigType.R6 then local clone = game.ServerStorage:WaitForChild("R6Sword") clone.Parent = player.Character elseif humanoid.RigType == Enum.humanoid.HumanoidRigType.R15 then local clone = game.ServerStorage:WaitForChild("R15Sword") clone.Parent = player.Character Character.humanoid.Died:Connect(function() local tag = Character.Humanoid:FindFirstChild("creator") if tag == nil then local player = tag.Value local XP = 10 local leaderstats = player:WaitForChild(leaderstats) leaderstats.XP.Value = leaderstats.XP.Value + XP end end) end end end) end) game.Players.PlayerRemoving:Connect(function(player) pcall(function() if player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("XP") and player.leaderstats.XP.Value > 0 then XPStore:SetAsync(player.UserId, player.leaderstats.XP.Value) end end) end)
I don't know why this happened but I guess. Any help?
The error is in the Enum, you shouldn't have Enum.humanoid.HumanoidRigType
you should have Enum.HumanoidRigType
, There is no need to change anything after the HumanoidRigType.